DBMS Assignment
DBMS Assignment
Question 2: Now create the Room, Booking, and Guest tables using the integrity
enhancement features of SQL with the following constraints:
(a) type must be one of Single, Double, or Family.
(b) price must be between £10 and £100.
(c) roomNo must be between 1 and 100.
(d) dateFrom and dateTo must be greater than today’s date.
(e) The same room cannot be double-booked.
(f ) The same guest cannot have overlapping bookings.
Question 3: Create a separate table with the same structure as the Booking table to hold
archive records. Using the INSERT statement, copy the records from the Booking table
to the archive table relating to bookings before 1 January 2003. Delete all bookings
before 1 January 2003 from the Booking table.
Question 5: Create a view containing the account for each guest at the Grosvenor Hotel.
Question 6: Give the users Manager and Director full access to these views, with the
privilege to pass the access on to other users.
Question 7: Give the user Accounts SELECT access to these views. Now revoke the
access from this user.
(a)
SELECT *FROM HotelBookingCount;
SELECT h.hotelNo, COUNT(*) FROM Hotel h,Room r, Booking b WHERE
h.hotelNo = r.hotelNo AND
r.roomNob.roomNo GROUP BY h.hotelNo;
(b)
SELECT hotelNo FROM HotelBookingCount WHERE hotelNo = ‘H001’;
SELECT h.hotelNo FROM Hotelh, Room r, Booking b WHERE h.hotelNo =
r.hotelNo AND r.roomNob.roomNo AND h.hotelNo = ‘H001’ GROUP BY
h.hotelNo;
(c)
SELECT MIN(bookingCount) FROM HotelBookingCount;