Generate the relational algebra, tuple relational calculus, and domain relational calculus expressions for the following queries:

(a) List all hotels.
(b) List all single rooms with a price below £20 per night.
(c) List the names and cities 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, guestName, and guestAddress) of all guests staying at the Grosvenor Hotel.


(a) List all hotels.
RA: Hotel
TRC: {H | Hotel(H)}
DRC: {hotelNo, hotelName, city | Hotel(hotelNo, hotelName, city)}
(b) List all single rooms with a price below £20 per night.
RA: ? type=‘S’ ? price < 20 (Room)
TRC: {R | Room(R)???R.type = ‘S’ ? R.price < 20}
DRC: {roomNo, hotelNo, type, price | (Room(roomNo, hotelNo, type, price) ?

type = ‘S’ ? price < 20)}
(c) List the names and cities of all guests.
RA: ? guestName, guestAddress (Guest)
TRC: {G.guestName, G.guestAddress | Guest(G)}
DRC: {guestName, guestAddress | (?guestNo)

(Guest(guestNo, guestName, guestAddress))}
(d) List the price and type of all rooms at the Grosvenor Hotel.

RA: ? price, type (Room hotelNo (? hotelName = ‘Grosvenor Hotel’ (Hotel)))
TRC: {R.price, R.type | Room(R) ????H) (Hotel(H) ? (?R.hotelNo = H.hotelNo) ?

(H.hotelName = ‘Grosvenor Hotel’))}

DRC: {price, type | (?roomNo, hotelNo, hotelNo1, hotelName, city)
(Room(roomNo, hotelNo, type, price) ? Hotel(hotelNo1, hotelName, city) ?
(hotelNo = hotelNo1) ? (hotelName = ‘Grosvenor Hotel’))}
(e) List all guests currently staying at the Grosvenor Hotel.
RA: Guest guestNo (? dateFrom ? ‘01-01-15’ ? dateTo ? ‘01-01-15’ (Booking hotelNo (? hotelName = ‘Grosvenor Hotel’ (Hotel))))
(substitute ‘01-01-15’ for today’s date).

TRC: {G |Guest(G) ? ((?B)(?H) (Booking(B) ??Hotel(H) ???B.dateFrom ? ‘01-01-15’) ?

(B.dateTo ? ‘01-01-15’) ? (B.guestNo = G.guestNo) ?
(B.hotelNo = H.hotelNo) ? (H.hotelName = ‘Grosvenor Hotel’)))}
DRC: {guestNo, guestName, guestAddress | (?hotelNo, guestNo1, dateFrom, dateTo,
hotelNo1, hotelName, city)
(Guest(guestNo, guestName, guestAddress) ?
Booking(hotelNo, guestNo1, dateFrom, dateTo) ?
Hotel(hotelNo1, hotelName, city) ?? (guestNo = guestNo1) ??
(dateFrom ? ‘01-01-15’ ? dateTo ? ‘01-01-15’) ?
(hotelNo = hotelNo1) ???hotelName = ‘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.
RA: (Room hotelNo (? hotelName = ‘Grosvenor Hotel’ (Hotel))) // Outer Join

? guestName, hotelNo, roomNo (
(Guest guestNo (? dateFrom ? ‘01-01-15’ ? dateTo ? ‘01-01-15’ (
Booking hotelNo (? hotelName=‘Grosvenor Hotel’ (Hotel))))
(substitute ‘01-01-15’ for today’s date).
TRC: {R, G.guestName | (Room(R) ??(?H)(Hotel(H) ?

(R.hotelNo = H.hotelNo) ???H.hotelName = ‘Grosvenor Hotel’))) ?
(Guest(G) ??((?B)(?H) (Booking(B) ? Hotel(H) ??
(G.guestNo ? B.guestNo) ? (B.hotelNo = H.hotelNo) ???
(H.hotelName = ‘Grosvenor Hotel’) ??
(B.dateFrom ? ‘01-01-15’ ??B.dateTo ? ‘01-01-15’)))}

DRC: {roomNo, hotelNo, type, price, guestName |
(?hNo, hName, city, hNo1, gNo1, dFrom, dTo, rNo)
(Room(roomNo, hotelNo, type, price) ??Hotel(hNo1, hName, city) ??
(hotelNo = hNo1) ? (hName = ‘Grosvenor Hotel’) ) ?
(Guest(guestNo, guestName, guestAddress) ? Hotel(hNo, hName, city) ?
Booking(hNo1, gNo1, dFrom, dTo, rNo) ??
(guestNo ? gNo1) ? (hNo1 = hNo) ??(hName = ‘Grosvenor Hotel’) ??
(dFrom ? ‘01-01-15’ ??dTo ? ‘01-01-15’)))}
(g) List the guest details (guestNo, guestName, and guestAddress) of all guests staying at the
Grosvenor Hotel.
RA: ? guestNo, guestName, guestAddress (Guest guestNo (? dateFrom ? ‘01-01-15’ ? dateTo ? ‘01-01-15’ (
Booking hotelNo (? hotelName=‘Grosvenor Hotel’ (Hotel)))))
(substitute ‘01-01-15’ for today’s date).

TRC: {G | Guest(G) ? ((?B) (?H) (Booking(B) ? Hotel(H) ??(B.guestNo = G.guestNo) ?
(B.hotelNo = H.hotelNo) ???H.hotelName = ‘Grosvenor Hotel’) ?
(B.dateFrom ? ‘01-01-15’ ?? B.dateTo ? ‘01-01-15’) ))}

DRC: {guestNo, guestName, guestAddress |

((?hNo, gNo, dFrom, dTo, rNo, hNo1, hName, city)
(Guest(guestNo, guestName, guestAddress) ?
Booking(hNo, gNo, dFrom, dTo, rNo) ? Hotel(hNo1, hName, city) ??
(guestNo = gNo) ? (hNo = hNo1) ???hName = ‘Grosvenor Hotel’) ?
(dFrom ? ‘01-01-15’ ?? dTo ? ‘01-01-15’) ))}

Computer Science & Information Technology

You might also like to view...

Cyberterrorists hack systems to conduct terrorist activities via network or Internet pathways. _________________________

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A list of sources consulted by an author in his or her work.

What will be an ideal response?

Computer Science & Information Technology

A layer style can only be applied to a type layer.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

On which menu is the Liquify feature located?

A. Edit B. View C. Filter D. Window

Computer Science & Information Technology