Database Systems Homework 2
Database Systems Homework 2
Home Assignment II
This assignment can be done in groups of at-most three students. All students of the group
should belong to the same lab/tutorial class.
IMPORTANT----Group of students from different lab/tutorial class will not be
accepted.
The following tables form part of a database held in a relational DBMS:Hotel
Room
Booking
Guest
where
Hotel contains hotel details and hotelNo is the primary key;
Room contains room details for each hotel and (roomNo, hotelNo) forms the primary
key, type may be single room, double room, etc. (Try to find from some hotel booking
agency website);
Booking contains details of the bookings and (hotelNo, guestNo, dateFrom) forms the
primary key;
Guest contains guest details and guestNo is the primary key.
(i) Identify the foreign keys in this schema. Explain how the entity and referential
integrity rules apply to these relations.
(ii) Produce some sample tables for these relations that observe the relational integrity
rules. Suggest at least 10 general constraints that would be appropriate for this
schema.
(iii) Write the relational algebra expressions for the following queries:
(a)
(b)
List all single rooms with a price below RM 200.00 per day.
(c)
(d)
List the price and type of all rooms at the Grand Hotel.
( e) List the guest details (guestNo, guestName, and guestAddress) of all guests currently
staying at the Grand Hotel.
(f ) List the details of all rooms at the Grand Hotel, including the name of the guest staying
in the room, if the room is occupied. (you will need outer join for this question)
Relational Algebra queries can also be run using Relational Algebra interpreter.
Extra credit of 5 marks for those who do the relational algebra queries using the interpreter.
https://code.google.com/p/relational-algebra/