USQ study material - Upload Student Web Pages
USQ study material - Upload Student Web Pages
USQ study material - Upload Student Web Pages
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Module 13 – Solutions 13.7<br />
5.31 Show that SQL is relationally complete.<br />
Hint: Allow the students to show that each of the relational algebra operations can be<br />
expressed in SQL.<br />
–<br />
13.3 Chapter 6 SQL: Data Definition<br />
Solutions and hints of some exercises<br />
6.7 CREATE TABLE Hotel(<br />
hotelNo CHAR(4) NOT NULL,<br />
hotelName VARCHAR(20) NOT NULL,<br />
city VARCHAR(50) NOT NULL,<br />
PRIMARY KEY (hotelNo));<br />
Or<br />
CREATE DOMAIN HotelNumber AS CHAR(4);<br />
CREATE TABLE Hotel(<br />
hotelNo HotelNumber NOT NULL,<br />
hotelName VARCHAR(20) NOT NULL,<br />
city VARCHAR(50) NOT NULL,<br />
PRIMARY KEY (hotelNo));<br />
6.8 Now create the Room, Booking, and Guest tables using the integrity enhancement<br />
features of SQL with the following constraints:<br />
(a) Type must be one of Single, Double, or Family.<br />
(b) Price must be between £10 and £100.<br />
(c) roomNo must be between 1 and 100.<br />
(d) dateFrom and dateTo must be greater than today’s date.<br />
(e) The same room cannot be double booked.<br />
(f)<br />
The same guest cannot have overlapping bookings.