๐Ÿ‘ฃ Walkthrough Examples

Watch a messy table get tidied, step by step

๐Ÿ“š Example 1: The School Library

The librarian keeps everything in one giant table. Every time a student borrows books, she adds a row:

Breaks a rule Repeated data
Table: Loans (the giant messy one ๐Ÿ˜ฑ)
StudentIDStudentNameFormGroupFormTeacherBooksBorrowed
001Amy10BMs LopezDracula, Frankenstein
002Ben10AMr KhanDracula
003Cara10BMs LopezFrankenstein, Holes, Wonder

Let's fix it โ€” one normal form at a time. ๐Ÿ’ช

Step 1 Get to 1NF โ€” one box, one value

๐Ÿ•ต๏ธ Spot the problem: the BooksBorrowed column has whole lists inside single cells. Amy's cell holds two books!

๐Ÿค” Think first: how would YOU fix it? Then click to reveal.

Give each borrowed book its own row. Yes, we repeat the student info for now โ€” we'll deal with that in the next steps!

โฌ‡๏ธ

โœ… Now in 1NF

Table: Loans
๐Ÿ”‘ StudentID๐Ÿ”‘ BookStudentNameFormGroupFormTeacher
001DraculaAmy10BMs Lopez
001FrankensteinAmy10BMs Lopez
002DraculaBen10AMr Khan
003FrankensteinCara10BMs Lopez
003HolesCara10BMs Lopez
003WonderCara10BMs Lopez

Every cell holds one value โœ…. The key is now StudentID + Book together (each pairing appears once).

โš ๏ธ But look at all that pink repeated data! Amy's details are typed once per book. 1NF is only level one โ€” onwards!

Step 2 Get to 2NF โ€” facts about the WHOLE key

๐Ÿ•ต๏ธ Spot the problem: our key is StudentID + Book. Ask of every other column: "do you need BOTH parts of the key, or just one?"

๐Ÿค” Think first: what should we do with those columns? Then click to reveal.

Move all the student facts into their own Students table, and leave the Loans table to record just who borrowed what.

โฌ‡๏ธ

โœ… Now in 2NF โ€” two tables

Amy's name now appears once, no matter how many books she borrows. The ๐Ÿ”— StudentID in Loans links back to the Students table.

โš ๏ธ Almost thereโ€ฆ but "Ms Lopez" still appears twice. Why? Because FormTeacher is really a fact about the FormGroup, not about the student. That's a job for 3NF!

Step 3 Get to 3NF โ€” nothing but the key

๐Ÿ•ต๏ธ Spot the problem: in the Students table, FormTeacher depends on FormGroup (an ordinary column) โ€” not on StudentID (the key). Every 10B student automatically has Ms Lopez.

๐Ÿค” Think first: how do we fix it? Then click to reveal.

Give form groups their own table. Students keep just the FormGroup code as a link.

โฌ‡๏ธ

โœ… Now in 3NF โ€” three tables, fully tidy! ๐ŸŽ‰

Every fact lives in exactly one place:

  • ๐Ÿ“• Who borrowed what โ†’ Loans
  • ๐Ÿ™‹ Who each student is โ†’ Students
  • ๐Ÿซ Who teaches each form โ†’ FormGroups

๐Ÿ• Example 2: The Pizza Shop (quicker run-through)

Try to spot each problem before opening the answer!

Table: PizzaOrders (messy!)
OrderIDCustomerNameCustomerPhonePizzasOrdered
P100Dev555-1234Margherita, Pepperoni
P101Ella555-9876Hawaiian
P102Dev555-1234Pepperoni
๐Ÿฅ‡ 1NF check: what's wrong? (click to reveal)

PizzasOrdered holds lists! Split them so each pizza on each order gets its own row. The key becomes OrderID + Pizza.

๐Ÿ”‘ OrderID๐Ÿ”‘ PizzaCustomerNameCustomerPhone
P100MargheritaDev555-1234
P100PepperoniDev555-1234
P101HawaiianElla555-9876
P102PepperoniDev555-1234
๐Ÿฅˆ 2NF check: which columns depend on only PART of the key? (click to reveal)

CustomerName and CustomerPhone depend only on OrderID โ€” not on which pizza. Move order facts to an Orders table:

๐Ÿฅ‰ 3NF check: is any column describing another ordinary column? (click to reveal)

CustomerPhone depends on CustomerName (well โ€” on the customer!), not on the OrderID. Dev's phone number is stored twice. Give customers their own table:

๐ŸŽ‰ Done! Three linked tables (OrderLines โžก๏ธ Orders โžก๏ธ Customers), every fact stored once.

๐Ÿงญ Your normalisation checklist

Use these three questions on ANY table, in order:

StepAsk yourselfโ€ฆIf YESโ€ฆ
๐Ÿฅ‡ 1NFIs there a list squashed into one cell?Split it into separate rows
๐Ÿฅˆ 2NFDoes any column depend on only part of a two-part key?Move it to its own table
๐Ÿฅ‰ 3NFDoes any column describe another ordinary column instead of the key?Move it to its own table
๐Ÿง  "The key, the whole key, and nothing but the key!"