Database Quires and Anamolies

The following tables form part of a database held in a relational DBMS:

 

Hotel
hotelNo hotelName city
101 Grosvenor London
102 Swallow London
201 Waldorf Astoria New York
202 Plaza New York
401 Sofitel Minneapolis

 

 

Guest
guestNo guestName guestAddress
40 John Smith 10 E 42 St, New York, NY
41 Mary Jones 110 Elm St, Garden City, NY
52 Thomas Smith 40-40 172 St, Flushing, NY
53 Joseph Schmo 1052 E 85 St, Brooklyn, NY
60 Ima Sample 3010 Broadway, New York, NY
61 Shesa Sample 2510 Utica Ave, Minneapolis, MN
62 George Seaver 41 Arschloch Rd, Grenewich, CT
63 Jerome Koosman 54 Morris Ave, Stillwater, MN

 

 

Room
roomNo hotelNo Type Price
201 101 Single 30
202 101 Double 40
203 101 Single 30
204 101 Double 40
205 101 Double 40
206 101 Suite 100
201 102 Single 25
202 102 Double 30
203 102 Single 25
204 102 Double 30
205 102 Double 30
206 102 Suite 80
201 201 Single 80
202 201 Double 100
203 201 Single 80
204 201 Double 100
205 201 Double 100
206 201 Suite 300

 

 

 

Booking
hotelNo guestNo dateFrom dateTo roomNo
101 40 8/12/2021 8/14/2021 201
101 52 10/12/2021 10/13/2021 204
101 63 10/24/2021 10/27/2021 206
201 40 8/24/2021 8/26/2021 205
201 40 10/31/2021 11/2/2021 203
201 52 10/28/2021 10/31/2021 201

 

 

 

 

 

 

1. Write SQL Queries and expected output for the following (Marks : 7)

a. How many hotels are there?

Select

b. List all double rooms (Hotel name & Room No) with a price below £40.00 per night, in ascending order of price.

c. How many different number of guests have made bookings for August?

d. What is the lost income from unoccupied rooms at the Grosvenor Hotel on 10/12/2021?

e. Increase the price of all rooms by 5%.

f. What is the most commonly booked room type for each hotel in London?

g. List all guests (Name) currently staying at the Grosvenor Hotel.

 

 

2. The table shown below lists sample dentist/patient appointment data. A patient is given an appointment at a specific time and date with a dentist located at a particular surgery. On each day of patient appointments, a dentist is allocated to a specific surgery for that day. (Marks: 13)

· The table shown below is susceptible to update anomalies. Provide examples of insertion, deletion, and update anomalies.

· Identify the functional dependencies represented by the attributes shown in the table. State any assumptions you make about the data and the attributes shown in this table.

· Describe and illustrate the process of normalizing the table shown to 3NF relations. Identify the primary, alternate, and foreign keys in your 3NF relations.

 

 

Dentist No Dentist Name Patient No Patient Name AppointmentDateTime SurgeryType
S1011 Tony Smith P100 Gillian White 12-Sep-2021 10:00 S15
S1011 Tony Smith P105 Jill Bell 12-Sep-2021 12:00 S15
S1024 Helen Pearson P108 Ian Mackay 12-Sep-2021 10:00 S10
S1024 Helen Pearson P108 Ian Mackay 14-Sep-2021 14:00 S10
S1032 Robin Plevin P105 Jill Bell 14-Sep-2021 16:30 S15
S1032 Robin Plevin P110 John Walker 15-Sep-2021 18:00 S13
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *