0% found this document useful (0 votes)
0 views

Week 8 tutorial

The document outlines a tutorial focused on relational database management systems (DBMS) with specific queries related to hotel and beer schemas. It includes tasks to evaluate the semantic correctness of SQL queries and to write new SQL statements based on provided relational schemas. Additionally, it covers SQL statements for motor insurance policy management, demonstrating practical applications of SQL in various contexts.

Uploaded by

Harry Borth
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Week 8 tutorial

The document outlines a tutorial focused on relational database management systems (DBMS) with specific queries related to hotel and beer schemas. It includes tasks to evaluate the semantic correctness of SQL queries and to write new SQL statements based on provided relational schemas. Additionally, it covers SQL statements for motor insurance policy management, demonstrating practical applications of SQL in various contexts.

Uploaded by

Harry Borth
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Week 2: Tutorial

1. The following table form part of a database held in a relational DBMS.

Hotel (hotelNo, hotelName, City)

Room (roomNo, hotelNo, type, price)

Booking (hotelNo, guestNo, datefrom, dateTo, roomNo)

Guest (guestNo, guestName, guestAddress, guestcardNo, expiryDate)

Using the above Hotel schema, determine whether the following queries are semantically correct.

a) SELECT r.type, r.price

FROM Room r, Hotel h

WHERE r.hotel_number = h.hotel_number AND h.hotel_name = ‘Grosvenor Hotel’ AND

r.type > 100;

b) SELECT g.guestNo, g.name

FROM Hotel h, Booking b, Guest g

WHERE h.hotelNo = b.hotelNo AND h.hotelName = ‘Grovesnor Hotel’;

c) SELECT r.roomNo, h.hotelNo

FROM Hotel h, Booking b, Room r

WHERE h.hotelNo = b.hotelNo AND h.hotelNo = ‘H21’ AND b.roomNo = r.roomNo AND

Type = ‘S’ AND b.hotelNo = ‘H22’;

2. Write the following queries based on the given relation schema.

Beers ( name, brewery)

Bars (name, addr, license)

Drinkers (name , addr, phone)

Likes( drinker, beer)

Sells (bar, beer, price)

Frequents (drinker, bar)


1. Find the address of Joe’s Bar
2. Find the beers produced by Labatt USA
3. Find the beers that are sold in Joe’s bar or at polar bar
4. Find all the beers priced at least 2£
5. Find the manufacturers of beers
6. Find the names of all beers that begin with letter ‘S’
7. Who drinks beers produced by Labatt USA
8. Count the distinct drinkers in Likes table.

3. Consider a relational data model for motor insurance policy management depicted below.

(a) Write an SQL statement to retrieve the first name and last name of all drivers who live in London
city.
(b) Write an SQL statement to list all policies which expire on 01/01/2017.
(c) Write an SQL statement to list all vehicles whose policy is worth more than ten thousand
pounds.
(d) Write an SQL statement to list the vehicle IDs owned for each driver licensed before 01/01/2009.

You might also like