OCR H446, section 1.3.2 (c)
Normalisation is a process for organising the tables of a relational database so that data is not duplicated and the structure is sound. You need to be able to normalise to third normal form (3NF).
Why normalise?
Badly designed tables suffer from redundancy, which causes anomalies.
| Problem | What goes wrong |
|---|---|
| Redundancy | The same fact is stored many times, wasting space |
| Update anomaly | A fact stored in many places must be changed in all of them, and if one is missed, the data contradicts itself |
| Insert anomaly | You can't add a fact without adding unrelated data (for example a new room can't be recorded until a guest books it) |
| Delete anomaly | Deleting a record also loses facts you wanted to keep (deleting the only booking for a room loses the room's details) |
Normalisation removes redundancy, avoids these anomalies, keeps data consistent, and makes the database easier to maintain and query.
The normal forms
First normal form (1NF)
- Every field holds a single (atomic) value, with no repeating groups or lists.
- There are no repeated columns (such as
Room1,Room2). - Each record is unique, with a primary key.
Second normal form (2NF)
- It is in 1NF, and
- there are no partial dependencies: every non-key attribute depends on the whole primary key, not just part of a composite key.
(A table with a single-field key in 1NF is automatically in 2NF.)
Third normal form (3NF)
- It is in 2NF, and
- there are no transitive dependencies: no non-key attribute depends on another non-key attribute. Each depends directly on the key.
Every non-key attribute depends on the key, the whole key, and nothing but the key.
A worked example: hotel bookings
A hotel records its bookings in a table. In the unnormalised form, one booking can include several rooms:
BOOKING (BookingID, GuestID, GuestName, GuestPhone, BookingDate, { RoomNo, RoomType, RoomPrice, Nights })
The primary key is underlined, a foreign key is followed by an arrow to its table, and { } marks the repeating group.
The curly brackets show a repeating group.
Step 1: reach 1NF
Remove the repeating group, so that there is one row for each room in each booking. The key is now composite: (BookingID, RoomNo).
| BookingID | RoomNo | GuestID | GuestName | GuestPhone | BookingDate | RoomType | RoomPrice | Nights |
|---|---|---|---|---|---|---|---|---|
| 501 | 12 | G1 | Asha Khan | 07700 900111 | 2026-11-02 | Double | 80 | 2 |
| 501 | 14 | G1 | Asha Khan | 07700 900111 | 2026-11-02 | Single | 55 | 2 |
| 502 | 12 | G2 | Ben Ortiz | 07700 900222 | 2026-11-05 | Double | 80 | 1 |
BOOKINGROOM (BookingID, RoomNo, GuestID, GuestName, GuestPhone, BookingDate, RoomType, RoomPrice, Nights)
Every cell is now atomic, but there is a lot of repeated data.
Step 2: reach 2NF
Look for partial dependencies on the composite key (BookingID, RoomNo).
GuestID,GuestName,GuestPhoneandBookingDatedepend onBookingIDonly (the booking).RoomTypeandRoomPricedepend onRoomNoonly (the room).Nightsdepends on both: how long this room is booked in this booking.
Split the table:
BOOKING (BookingID, GuestID, GuestName, GuestPhone, BookingDate)
ROOM (RoomNo, RoomType, RoomPrice)
BOOKINGROOM (BookingID → BOOKING, RoomNo → ROOM, Nights)
Step 3: reach 3NF
Look for transitive dependencies (a non-key attribute depending on another non-key attribute).
- In
BOOKING,GuestNameandGuestPhonedepend onGuestID, which is not the key. The chain isBookingIDtoGuestIDtoGuestName. - In
ROOM,RoomPricedepends onRoomType, if the price is set by the type. That would be another transitive dependency, so we could add aROOMTYPE (RoomType, RoomPrice)table. (In many exam questions the data in the question tells you which dependencies exist.)
Split out the guests (and, here, the room types):
GUEST (GuestID, GuestName, GuestPhone)
BOOKING (BookingID, GuestID → GUEST, BookingDate)
ROOMTYPE (RoomType, RoomPrice)
ROOM (RoomNo, RoomType → ROOMTYPE)
BOOKINGROOM (BookingID → BOOKING, RoomNo → ROOM, Nights)
The primary keys are the first field of GUEST, BOOKING, ROOMTYPE and ROOM, and the composite (BookingID, RoomNo) in BOOKINGROOM. The foreign keys are GuestID in BOOKING, RoomType in ROOM, and BookingID and RoomNo in BOOKINGROOM.
The result
Each fact is stored once:
- a guest's phone number is in one place, so it takes one update to change it (no update anomaly);
- a new room or room type can be added before anyone books it (no insert anomaly);
- deleting a booking doesn't lose the guest's or the room's details (no delete anomaly).
Properties of a relation in 3NF
- All attributes are atomic (1NF).
- There are no partial dependencies (2NF).
- There are no transitive dependencies (3NF).
- All non-key attributes depend on the key, the whole key and nothing but the key.
Worked example
Task: PUPIL (PupilID, Name, FormID, FormTutor). Is it in 3NF? If not, normalise it.
FormTutordepends onFormID, which is a non-key attribute. This is a transitive dependency (PupilIDtoFormIDtoFormTutor), so the table is not in 3NF. The key is a single field, so it is already in 2NF.- Split it:
PUPIL (PupilID, Name, FormID → FORM)
FORM (FormID, FormTutor)
FormID in PUPIL is now a foreign key. The tutor's name is stored once, so changing the tutor of a form takes one update.
Exam tip: work through the stages in order, and say what you are removing at each: a repeating group (1NF), a partial dependency (2NF), a transitive dependency (3NF). Show the final tables with primary keys and foreign keys marked.
Check yourself
Give two reasons for normalising a database
Any two of: it removes redundant data; it avoids update, insert and delete anomalies; it keeps the data consistent; it makes the database easier to maintain.
What is a partial dependency?
A non-key attribute that depends on only part of a composite primary key, instead of the whole key.
What is a transitive dependency?
A non-key attribute that depends on another non-key attribute, instead of directly on the primary key.
What must be true for a table to be in third normal form?
It must be in second normal form with no transitive dependencies, so every non-key attribute depends on the key, the whole key and nothing but the key.