You are on page 1of 9

DATABASE

NORMALISATION

Normalisation is a technique for ensuring our database is structured correctly. When


a database is structured properly there will be…

● No repeating data.
● No chance of anomalies when updating, deleting or adding data
● No chance of data inconsistencies

There are three stages to normalisation:

1st Normal Form

2nd Normal Form

3rd Normal Form

You have to understand what each stage is and be able to normalise data.

Work through this document and complete the tasks.


FIRST NORMAL FORM
What is first Normal form? Watch this video first:

Below is a table used to store appointments at a dentist. It is unnormalised (0NF). As you


can see there are issues that do not make it first normal form

Dentist Dentist Name Appointments


ID

1 Dr Fi Ling, PART TIME 10:15 10/04/2020, F Khan, 0736355357


9:30 11/05/2020, G Brown, 0778892827

2 Dr Ruth Cannal, FULL TIME 12:00 11/04/2020, P Smythe, 07383833391


10:00 12/05/2020, J Jones
10:30 12/05/2020, C Pritchard, 07922238381

3 Dr Phil McCavity, FULL TIME 9:30 05/05/2020, R Patel, 07777478891

Identify TWO examples of why attributes in this table that are not in FIRST NORMAL FORM

1.
Many values in dentist name
Part time and fulltime

2.

Missing value in appointments


As a result we redesign this into two tables (relations) called DENTIST and APPOINTMENT.

Question : Complete the tables to show what attributes (fields, columns) would go into
each table so that the data is now in 1st Normal Form.
Some attributes have already been added for you.

DENTIST

Attributes

Dentist ID

Dentist name

Appointments

APPOINTMENTS

Attributes

Appointment ID

Appointment Time

Appointment Date

Customer Name

Customer mobile number

Dentist ID

Question - Explain why Dentist ID has been added to the APPOINTMENTS table(relation)
as well as the DENTIST table(relation)

Acts as a fine key to link the two tabels

SUMMARY - 1st Normal Form


There are no repeating groups of data, all attributes have atomic data.
SECOND NORMAL FORM
What is Second Normal form? Watch this video first:

Here is a database used by an online retailer to record orders and customers. The
customer table isn’t displayed here but you can assume it stores all the information about
customers accessible by their Customer ID. For that reason the customer ID is a FOREIGN
KEY in this table.

Customer Product ID Product Product Quantity Date


ID Desc Price Purchased Purchased

1 1 Lawnmower £35.99 1 01/06/2020

1 2 Rake £7.99 1 01/06/2020

1 3 Plant Pot £1.50 6 01/06/2020

2 2 Rake £7.99 2 03/06/2020

2 3 Plant Pot £1.50 5 03/06/2020

1 3 Plant Pot £1.50 6 04/06/2020

4 1 Lawnmower £35.99 1 25/05/2020

There is no single attribute here that is UNIQUE i.e. different for each row(tuple) of the
table(relation) here. Therefore we have to use a COMPOSITE KEY made up of more than
one.

Question: What 3 attributes combined would be a unique combination for each row?

Customer ID

Product ID

Date purchased
Second normal form is only an issue for tables that have COMPOSITE KEYS.

Important: Tables with a single key attribute are already in 2nd normal form.

We need to look at all the attributes that are NOT part of the composite key in your
answer to the last question.

Which of these DEPEND (could be found) only when you know ALL THREE of the key
attributes or which are only PARTIALLY DEPENDENT on knowing one or two of the key
attributes.

Question : Mark all attributes with an ‘X’ in the last row that are only PARTIALLY
DEPENDENT on the composite key.

The composite key attributes are filled in grey.

Customer Product ID Product Product Quantity Date


ID Desc Price Purchased Purchased

1 1 Lawnmower £35.99 1 01/06/2020

1 2 Rake £7.99 1 01/06/2020

1 3 Plant Pot £1.50 6 01/06/2020

2 2 Rake £7.99 2 03/06/2020

2 3 Plant Pot £1.50 5 03/06/2020

1 3 Plant Pot £1.50 6 04/06/2020

4 1 Lawnmower £35.99 1 25/05/2020

Partially dependent: X X
Now that you have identified the partial key dependencies we can divide this table into two.
Complete the attributes for the two tables below

ORDERS

Attributes

Customer ID

Product ID

Date Purchased

Quantity purchased

PRODUCTS

Attributes

Product ID

Product Price

Product desc

SUMMARY - 2nd Normal form.

ALL attributes that are not part of the composite key depend on the whole key.
THIRD NORMAL FORM
What is Third Normal form? Watch this video first:

Here is a table that is in 2nd normal form used to store team details for a local league.

Team ID Title Home Kit Manager Manager


(KEY ground Colour Name Tel.
ATTRIBUTE)

1 Stockport Stockport Blue and F Briggs 07982345367


Vikings Lads Club White

2 Mountfield Bramhall Purple T Rogers 07865544332


Rovers Rec

3 Hazel Grove Hazel Grove Red G Bastani 07745653434


High

Question: There is a transitive functional dependence here - in other words there are
attributes that depend on other attributes which are not the key attribute. Can you spot it?

CLUE: Look for any non-key attributes that if you had to change them for whatever reason
then you would have to change another attribute as well.

Mark with an ‘X’ those attributes

Title Home ground Kit Manager Manager


Colour name Tel.

x x
This would mean separating this table into two tables. Remember they will need to be
linked

TEAM

Attributes

Team ID (primary key)

Title

Homeground

Kit Colour

Manager name

MANAGER

Attributes

Manager Name (primary key)

Manage Telophone number

SUMMARY - 3rd Normal form.

ALL attributes that are not part of the key only depend on the key and not on any other
non-key attributes.

Now try the following example on the next page...


NORMALISATION EXERCISE
Now try to normalise the following data. You don’t have to go through the different
stages just make sure the data is in third normal form.

Here is an unnormalized table used to store exam results in a college. Convert this
into a two or more normalised tables

Student Student Subject Subject Test Test Test grade


ID Name ID Code Score Max

1 Fred 1 Maths MAT1 35 50 B


Pye

1 Fred 2 Art ART1 44 70 C


Pye

1 Fred 3 IT IT1 44 50 A
Pye

2 Jane 1 Maths MAT1 13 50 E


Carr

2 Jane 1 Maths MAT2 67 100 B


Carr

3 Max 3 IT IT1 33 50 B
Jones

3 Max 3 IT IT2 34 70 D
Jones

Write out your solution here..

You might also like