You are on page 1of 3

Normalisation

Normalisation is the process of analysing how to make databases more efficient by using separate tables
to reduce redundant data. When a database is normalised, data is broken down into smaller tables and
relationships are used to link them.

Connecting entities

The main characteristics of a relational database are:

 it is built from a set of unique tables (also called relations)


 a table contains data about just one entity
 tables must have a primary key
 tables are linked by primary and foreign keys

When working with relational databases, users need to try to keep information about different entities
in separate tables. Each entity has a primary key to provide a unique reference to an entity, which means
that an entity can be referenced in another table without having to call up all the details about that entity.

Entity relationship diagrams


Entities can relate to each other in three different ways: one to one, one to many and many to many.

You can represent these relationships using an entity relationship diagram (ERD).

One to one

For example, one person has one address.

One to many

For example, one cinema has many customers.

Many to many

For example, many subjects can be taken


by many students.

Relationship example
The following example shows how tables can be connected using primary and foreign keys.
The tables are in a database for an online shop. There are three tables:
 customer
 product
 orders
Each table has a primary key field and each record has a primary key with a unique number.
Customer table
The customer table gives customers a unique Customer ID (the primary key for this table) and shows
customer details, i.e. name, address and phone number.

Customer ID First name Surname Address Phone number


02942 Rebecca Johnson 49 Drew Road 029 381834
Customer ID First name Surname Address Phone number
02943 Mushtaq Aqbar 28 Lyttleton Lane 028 282738

Product table
The product table gives details about the products. The Product ID is the primary key for this table.

Product ID Product type Colour Size Cost


284758 Jeans Blue 28 £14.99
384957 Shoes Brown 6 £12.99
483927 Jumper Red M £29.99
489320 Shirt Blue M £33.99
839258 Socks White 6 £10.00

Orders table
In the orders table, each order has a unique Order number (the primary key for this table). The table also
includes customer ID (the primary key of the customer table) and product ID (the primary key of the
product table) as foreign keys, but does not need to include all details about customers and products as
these are stored in the Customer and Product tables.

Order number Customer ID Product ID Quantity Total cost


59876 02942 284758 2 £29.98
59877 02942 384957 3 £38.97
59878 02942 483927 1 £29.99
59879 02943 489320 3 £101.97
59880 02943 839258 2 £20.00

Normalisation

If the Orders table did not use Customer ID and Product ID fields, it would need to include additional
fields from the Customer table and the Product table – an extra eight fields. It would also need to repeat
the same customer details for each order. The Orders table would be much larger, use more data, and be
repetitive.

This table shows how the orders table would look without normalisation:

Order Phone Product Total


First name Surname Address Colour Size Cost Quantity
number number type cost
49 Drew 029
59876 Rebecca Johnson Jeans Blue 28 £14.99 2 £29.98
Road 381834
Order Phone Product Total
First name Surname Address Colour Size Cost Quantity
number number type cost
49 Drew 029
59877 Rebecca Johnson Shoes Brown 6 £12.99 3 £38.97
Road 381834
49 Drew 029
59878 Rebecca Johnson Jumper Red M £29.99 1 £29.99
Road 381834
28 Lyttleton 028
59879 Mushtaq Aqbar Shirt Blue M £33.99 3 £101.97
Lane 282738
28 Lyttleton 028
59880 Mushtaq Aqbar Socks White 6 £10.00 2 £20.00
Lane 282738

Normalising the data creates a selection of simpler tables which takes up less data.

You might also like