Answered step by step
Verified Expert Solution
Link Copied!

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
c10 Davood Edmonton Canada 20
c20 John Victoria Canada 65
cid rid arrival departure
c10 r3002021/12/172021/12/27
c20 r2002021/12/242022/01/03
resorts
rid resort city country suites
r200 Andaz Guanacaste Costa Rica 80
r300 Dreams Sands Cancun Mexico 60
r
Express the following queries in SQL. In each case, write a single SQL statement.
a)[4 marks] Find the name and the city of customers who have booked a resort in
Mexico.
b)[4 marks] Find the rid of resorts with at least 80% of their bookings made by
customers from Canada.
c)[4 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
r200 Andaz Guanacaste Costa Rica 80
r300 Dreams Sands Cancun Mexico 60
resorts
CMPUT 291/ A1 Final Exam - Fall Page 4 of 9
d)[4 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 3
[4 marks ] Based on the schema in Question 2, 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 30 or less.
Question 4
[4 marks ] Based on the schema in Question 2, 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

What is the difference between JDBC, JNDI and Hibernate?

Answered: 1 week ago

Question

9. Describe the characteristics of power.

Answered: 1 week ago