Map the object-oriented design for the Hotel case study produced in Exercise 27.22 to the ODMG ODL.

class Hotel {
(extent hotels key hotelNo)
attribute string hotelNo;
attribute string hotelName;
attribute string city;
relationship set Contains inverse Room::ContainedIn;

}
class Room {
(extent rooms key hotelNo, roomNo)
attribute string hotelNo;
attribute string roomNo;
attribute string hotelName;
attribute string city;
relationship ContainedIn inverse Hotel::Contains;
relationship set Gets inverse Booking::MadeFor;
changeRoomPrice(in roomNo:string, in float) raises(noSuchRoom);
changeRoomType(in roomNo:string, in char) raises(noSuchRoom);

}
class Guest {
(extent guests key guestNo)
attribute string guestNo;
attribute string guestName;
attribute string guestAddress;
relationship set Makes inverse Booking::MadeFor;
Show how the following queries would be written in OQL:
(a) List all hotels.
(b) List all single rooms with a price below £20.00 per night.
(c) List the names and addresses of all guests.
(d) List the price and type of all rooms at the Grosvenor Hotel.
(e) List all guests currently staying at the Grosvenor Hotel.
(f) List the details of all rooms at the Grosvenor Hotel, including the name of the guest staying in the room, if the room is occupied.
(g) List the guest details (guestNo, name and address) of all guests staying at the Grosvenor Hotel.


(a) hotel
or to sort them:
sort h IN Hotel by h.name
(b) SELECT h.rooms
FROM h IN hotel
WHERE h.rooms.price < 20
(c) SELECT STRUCT(name:g.name, address:g.address)
FROM g IN guest
(d) type prices {attribute price : float; type: char;}
prices (SELECT STRUCT(price:h.rooms.price, type:h.rooms.type)
FROM h IN hotel
WHERE h.name = ‘Grosvenor Hotel’
(e) SELECT g
FROM g IN guests
b IN g.booked_for
h IN b.booking_for
WHERE b.dateFrom <= ‘01-01-05’ AND
b.dateTo <= ‘01-01-05’ AND
h.name = ‘Grosvenor Hotel’
(substitute ‘01-01-05’ for today’s date).
(f) define occupied as
SELECT STRUCT(h.rooms,
SELECT g.name
FROM g IN guest
b IN g.booked_for
h IN b.booking_for
WHERE b.dateFrom <= ‘01-01-15’ AND
b.dateTo <= ‘01-01-15’ AND
h.name = ‘Grosvenor Hotel’)

FROM h IN hotel
UNION
SELECT STRUCT(h.rooms, nil)
FROM h IN hotel, y IN occupied
WHERE h.rooms.roomNo != y.roomNo
(substitute ‘01-01-15’ for today’s date).
(g) SELECT STRUCT(guestNo:g.guestNo, name:g.name, address:g.address)
FROM g IN g IN guest
b IN g.booked_for
h IN b.booking_for
WHERE b.dateFrom <= ‘01-01-15’ AND
b.dateTo <= ‘01-01-15’ AND
h.name = ‘Grosvenor Hotel’
(substitute ‘01-01-15’ for today’s date).

Computer Science & Information Technology

You might also like to view...

An example of a container is a/an:

a. array b. vector c. linked list d. all of the above

Computer Science & Information Technology

The improved Bluetooth 2.0 increased the data rate to around ____ Mbps.

A. three B. four C. five D. six

Computer Science & Information Technology

When text is ________ it means the text is as close to the left margin as possible without forcing a word to break

A) ragged right B) justified C) ragged left D) centered

Computer Science & Information Technology

Match the following terms to their meanings:

I. Text alignment II. Sizing handles III. Rotation handle IV. List levels V. Aspect ratio A. left, right, justified, or centered B. provides a way to rotate the selected image C. the ratio of the width to height of a display D. indicate a selected picture E. similar to outline levels

Computer Science & Information Technology