Homework 3 Introduction to SQL
Unit 11 Databases and software development
Homework 3 Introduction to SQL
1. A second-hand car dealer keeps a record of customers who have purchased cars.
The data held on each table includes the following fields:
Customer
Car
(a) Write the entity descriptions for the entities Customer and Car in the format:
Entity(attribute1, attribute2, ….) [2]
(b) Identify primary and foreign keys, where they exist, in both tables. [2]
(c) Draw an entity relationship diagram showing the relationship between
the two tables. [2]
1
Homework 3 Introduction to SQL
Unit 11 Databases and software development
(d) Write an SQL statement using keywords SELECT… FROM… WHERE…ORDER BY
to extract a list of the make, model, year registered and price of all 5-door cars costing
less than £2000, sequenced in descending order of price. [4]
(e) Write an SQL statement using keywords SELECT… FROM… WHERE…ORDER BY
to extract a list, sequenced by surname and initials, of customer IDs, surnames, initials
and email addresses of all customers who purchased cars between 2009 and 2011
inclusive, together with the make of car and price paid. [6]
(f) Write an SQL statement to extract all the details of cars
with make beginning with “V”.
[2]
(g) The Car database is in Third Normal Form. Explain what this means. [2]
Total 20 marks