
PUZZLE 6 HOTEL RESERVATIONS 21
PUZZLE
6 HOTEL RESERVATIONS
Scott Gammans posted a version of the following problem on the
WATCOM Forum on CompuServe. Suppose you are the clerk at Hotel
SQL, and you have the following table:
CREATE TABLE Hotel
(room_nbr INTEGER NOT NULL,
arrival_date DATE NOT NULL,
departure_date DATE NOT NULL,
guest_name CHAR(30) NOT NULL,
PRIMARY KEY (room_nbr, arrival_date),
CHECK (departure_date >= arrival_date));
Right now the CHECK() clause enforces the data integrity constraint
that you cannot leave before you have arrived, but you want more. How
do you enforce the rule that you cannot add a reservation that has an ...