You are on page 1of 4

SQL Unit Test

Section 1:

A car club wants to store details about cars in a structured database consisting of the following
format:
Cars (Reg No, Make, Model, Colour, Engine_Size, Year, Estimated_Value, MemberID)

Member (MemberID, Forename, Surname, Email_Address, Address, Postcode,


Member_Since, Renewal_Date)

1. Before they go ahead and create the database they realise they must set up the structure
and relationships of the database

a. What is meant by a primary key? (1)

____________________________________________________________________

b. What would be the primary key in the Cars Table? (1)

____________________________________________________________________

c. What would be the Primary key in the Members table? (1)

____________________________________________________________________

d. Why is there another MemberID field in the Cars table? (2)

___________________________________________________________________

2. They decide to setup their database using SQL. Write the SQL statement that would CREATE
the Cars table. (12)

3. Dave joined the car club on 21st February for 1 year. Using his details below write the SQL to
add his details to the database.
Dave Freeman, d.freeman@hotmail.com, 21 Academy Place, TW5 6DF. He owns a
Red Ferrari 355, reg number LV54 1LX, made in 1994, 3.5L engine worth £78,000.
(4)
4. Nick is a member of the club. His MemberID is 0012. He wants to know the Make, Model
and value of all his cars.

Write an SQL query to display his cars in highest value order. (4)

5. Nick recently renewed his membership on the 1st January 2014 for 2 years. Write the SQL to
update his details (3)

6. Darcy (MemberID 0014) has decided to leave the club. Write the SQL statement to delete
her details from the members table and her car with the registration number JG03 9PO. (4)
7. Bob is organising a car fair and wants to showcase the most expensive cars. Write the SQL
statement to show all the data about cars that are worth more than £150,000 in ascending
value order. (3)

Section 2:

1. Miss Henken is trying to setup a database to store data about the next activity day at school
whereby one student can do more than 1 activity but not the same activity. She has
identified the following fields and has asked you to design an efficient data structure to
store data for the pupils taking part in the activities.

Fields: Pupil_Name, Activity, Form, Student_ID, Cost, Activity location, Lead member of staff,
number of places, Activity_ID

a. Using the above field names complete columns 1 & 2 below by:
i. identifying suitable table names for the fields (2)
ii. Placing each of the fields in the most appropriate table(s) you have
identified (2)
b. In column (3) identify the most appropriate data type for each field (2)
c. In column (4) write PRIMARY on the field(s) you identify to be the primary key and
FORIEGN where you identify FOREIGN key(s). (3)
1. Table 2. Field 3. Data Type 4. Primary or
name: Foreign Key?

You might also like