You are on page 1of 1

CO5022 – Database Principles and Practice

Week 2 - SQL - Structured Query Language – Part 1


These exercises should be done on paper initially – remember you will not have a computer in the exam.
Scenario
All these exercises use the Agency database which has three linked tables as shown below:-

The hotels table is the same as the one you created last week
Creating the Database
Using the web creation tool at https://fse.studentwebserver.co.uk/Databases/SQL2014 create a new database called
Agency. Set the password to P@55word.
Creating the tables
1. Now open SQL Management Studio 2014 and login with the server name SQL2014.studentwebserver.co.uk and
the user name and password from the web dialog.
2. Open a new query by clicking New Query
3. Download the script Agency.sql from the learning materials website and copy it into the blank query window you
just created.
4. Edit the first line of the script, replacing 0000000 with your student number and then run the query by pressing
Execute
5. If you have been successful, you will get a series of messages like this:-
(1 row(s) affected)

Now you can try the exercises below:-


Easy Exercises
1. List full details all the Hotels in Dunkeld
2. List the names and phone of hotels in Pitlochry with over 10 beds
3. List emails and addresses of all clients from Liverpool
4. List full details of all bookings over 3 nights
5. List the Room Numbers of clients who had dinner at the hotel with the code BIRN

Harder Exercises
6. List the Room Numbers of clients who had dinner at The Crieff Hotel
7. List the Fullnames (as a calculated field) and telephones of all clients
8. List the Fullnames of all clients who stayed an hotel in June 2000
9. Which hotel was visited by a client from Hull in 2000?
10. From what towns have clients come to stay at Birnam Hotel for more than two nights?

You might also like