Question
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
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