Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a relational database about hotels, customers (guests) and their bookings that are maintained by an online hotelbooking company. The database consists of the following

Consider a relational database about hotels, customers (guests) and their bookings that are maintained by an online hotelbooking company. The database consists of the following tables (where the primary keys are underlined):

Hotel (hId, hName, hAddress, hCity)

Guest(gId, gName, gAddress, gCity)

Room(hid, roomNo, type, price )

Booking(gId, hId, roomNo, fromDate, year, noOfDays)

The Booking relation indicates that a guest booked a hotel room for a specified number of days (noOfDays) starting from fromDate of a given year. For instance, a tuple < g12345, h5555, 220, Jan05, 2005, 8> in Booking indicates that guest g12345 booked room 220 of the h5555 hotel for 8 days starting on Jan 5, 2005. The attribute "gAddress" records the home address of the guests.

Write the following queries in relational algebra:

(1) Return the name of guests who have booked a hotel room in NYC in January 2017 (tips: "January 2017' = "Jan01, 2017 to Jan31, 2017".

(2) Return the name of guests who have booked a hotel room of type suite in NYC for longer than 10 days.

(3) Return the name of guests who never booked a hotel room for longer than 5 days.

(4) Return the IDs of the hotels located in NYC which were not booked at all in the year 2017.

(5) Return the ids of the guests who have booked at least one room of type suite in every hotel located in NYC.

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions