Worksheet 3 Normalisation
Unit 4 Exchanging data
Worksheet 3 Relational databases and normalisation
Answers
1. Write definitions for
First Normal Form (1NF)
A table is in 1NF if it contains no repeating attributes or groups of attributes and all
attributes are atomic
Second Normal Form (2NF)
A table is in 2NF if it is in 1NF and contains no partial dependencies
Third Normal Form (3NF)
A table is in 3NF if it is in 2NF and contains no non-key dependencies
2. A car dealer has several different branches which each sell cars, and a database is being
designed to hold data about the cars they sell and the salespeople who sell them
Each branch is identified by town. There is a maximum of one branch in each town.
Each make of car is identified by a unique model name
Each model of car is made by only one manufacturer
Each salesperson is identified by their SalesID. The number of each model of car that
they sell (SalesVol) is recorded
A first attempt at designing a table to hold the data has been made. The table, called
CarSales, is shown below with some sample data.
SalesID Name Branch Model SalesVol Manufacturer
(a) Why is this table not in First Normal Form (1NF)?
Clio 3 Renault
It contains repeating
S123 Gerry groups of attributes C3
Norwich (Model, SalesVol
Picasso 4 and Manufacturer)
Citroen
Civic 5 Honda
Juke 1 Nissan
S555
(b) The data is Shirley CromerShow the
split into two tables. C4contents of the
2 two tables Citroen
Octavia 4 Skoda
Table: SalesPerson C3 Picasso 5 Citroen
S442 Dave Cromer
Octavia 1 Skoda
SalesID Name Branch
S123 Gerry Norwich
S555 Shirley Cromer
S442 Dave Cromer
SalesID Model SalesVol Manufacturer
S123 ProductSales
Table: Clio 3 Renault
S123 C3 Picasso 4 Citroen
S123 Civic 5 Honda
S555 Juke 1 Nissan
S555 C4 2 Citroen
S555 Octavia 4 Skoda 1
S442 C3 Picasso 5 Citroen
S442 Octavia 1 Skoda
Worksheet 3 Normalisation
Unit 4 Exchanging data
(c) A relationship between the tables has been implemented. Explain how this has been
done.
There is a one-to-many relationship between SalesPerson and ProductSales created
by holding SalesID as a foreign key in the ProductSales table
(d) Explain why the ProductSales table is not in Third Normal Form (3NF)
The primary key of the ProductSales table is a composite key, SalesID and Model.
Manufacturer is not dependent on the whole key, it is dependent only on the Model.
(This is a partial dependency, so it is not in 2NF, and therefore not in 3NF.)
(e) Draw an entity relationship diagram to show the entitities in the database in 3NF.
SalesPerson ProductSales Product
(f) Write the table definitions for the database in 3NF. Use the notation
Tablename (keyfield, Attribute1, Attribute2, …)
SalesPerson (SalesID, Name, Branch)
ProductSales (SalesID, Model, SalesVol)
Product (Model, Manufacturer)
(g) Identify the foreign key(s) in one of the tables.
SalesID, Model in the ProductSales table