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) RA: Hotel
TRC: {H | Hotel(H)}
DRC: {hotelNo, hotelName, city | Hotel(hotelNo, hotelName, city)}
(b) 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) RA: ? guestName, guestAddress (Guest)
TRC: {G.guestName, G.guestAddress | Guest(G)}
DRC: {guestName, guestAddress | (?guestNo)
(Guest(guestNo, guestName, guestAddress))}
(d) 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) 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) 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) 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...

Having a this reference allows:

a) A method to refer explicitly to the instance variables and other methods of the object on which the method was called. b) A method to refer implicitly to the instance variables and other methods of the object on which the method was called. c) An object to reference itself. d) All of the above.

Computer Science & Information Technology

Draw a simplified decision tree that shows the discount rules.

What will be an ideal response?

Computer Science & Information Technology