Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the following tables with the primary key of each table underlined, and a few sample tuples shown. The columns cid and rid in bookings
Consider the following tables with the primary key of each table
underlined, and a few sample tuples shown. The columns cid and rid in bookings are
foreign keys referencing customers and resorts respectively.
R S R S R S
cid name city country age
c Davood Edmonton Canada
c John Victoria Canada
cid rid arrival departure
c r
c r
resorts
rid resort city country suites
r Andaz Guanacaste Costa Rica
r Dreams Sands Cancun Mexico
r
Express the following queries in SQL In each case, write a single SQL statement.
a marks Find the name and the city of customers who have booked a resort in
Mexico.
b marks Find the rid of resorts with at least of their bookings made by
customers from Canada.
c marks Find the names of all pairs of different customers from Edmonton such
that both customers stay in the same resort and the days of their stays overlap.
rid resort city country suites
r Andaz Guanacaste Costa Rica
r Dreams Sands Cancun Mexico
resorts
CMPUT A Final Exam Fall Page of
d marks For each country and city that has a resort, list the country and the city,
the number of resorts and the number of resorts with a customer booking from
Canada.
Question
marks Based on the schema in Question write a relational algebra or a relational
calculus query but not both to find the rid of resorts that have no booking for customers
of age or less.
Question
marks Based on the schema in Question write a SQL assertion to enforce that
no resort can have more bookings ignoring the dates than the number of suites in the
resort.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started