Normalisation Basics, Written Out: Untangling a Messy Spreadsheet

Normalisation is easiest to understand by doing it. In this written walkthrough, organised in chapters like a short video (no video is published), we take a messy club spreadsheet and turn it into tidy tables.

Joining two tables illustration

Chapter 1: the mess

A running club tracks members and their races in one sheet:

memberemailracescoachcoach_phone
Anaana@example.org5k, 10kSam0700 000 001
Benben@example.org10kSam0700 000 001
Cleocleo@example.org5k, half marathonRita0700 000 002

(The phone numbers are made-up placeholders.) Notice two problems: the races cells hold lists, and coach details repeat on every row.

Chapter 2: one value per cell

First rule: no lists in cells. We give each member-race pair its own row:

memberrace
Ana5k
Ana10k
Ben10k
Cleo5k
Cleohalf marathon

Now "who ran the 10k?" is a simple filter instead of a text search through commas.

Chapter 3: one fact in one place

Sam's phone number appears on every row for Sam's runners. If it changes, we must edit many rows. So coaches get their own table:

coach_idnamephone
1Sam0700 000 001
2Rita0700 000 002

Members point to their coach by id:

member_idnameemailcoach_id
1Anaana@example.org1
2Benben@example.org1
3Cleocleo@example.org2

Chapter 4: races as their own thing

Race names are typed by hand in the pairs table, so "10k" and "10 k" could sneak in. We make a races table and link to it:

race_idname
15k
210k
3half marathon

And the pairs become ids only:

member_idrace_id
11
12
22
31
33

This "pairs" table is called a linking table (or junction table). It records a many-to-many relationship: a member runs many races, and a race has many members.

Chapter 5: the SQL

CREATE TABLE coaches (coach_id INTEGER PRIMARY KEY, name TEXT NOT NULL, phone TEXT);
CREATE TABLE members (member_id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE,
                      coach_id INTEGER REFERENCES coaches(coach_id));
CREATE TABLE races (race_id INTEGER PRIMARY KEY, name TEXT NOT NULL UNIQUE);
CREATE TABLE member_races (member_id INTEGER REFERENCES members(member_id),
                           race_id INTEGER REFERENCES races(race_id),
                           PRIMARY KEY (member_id, race_id));

Chapter 6: getting the full picture back

Splitting does not lose anything; a JOIN puts it back together:

SELECT m.name, r.name AS race, c.name AS coach
FROM member_races mr
JOIN members m ON m.member_id = mr.member_id
JOIN races   r ON r.race_id   = mr.race_id
JOIN coaches c ON c.coach_id  = m.coach_id
ORDER BY m.name;

What we gained

BeforeAfter
Lists inside cellsOne value per cell
Coach phone repeatedStored once
Race names typed many timesOne races table with unique names
Hard to add a coach with no runnersJust add a coaches row

For the reasoning behind each step, read inside normalisation: why we split data into tables.

A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.

Illustrative outline only: no live session, recording, registration or certificate is offered on this site. Any speakers, panels or schedules mentioned are hypothetical.

Related pages on this site