Find a course

Module 3: NormalizationLesson 7 of 1216 min

First, Second and Third Normal Form

Normalize a messy orders table step by step into 1NF, 2NF and 3NF, and check each resulting table against the rule it must satisfy.

Step 1 of 14Learn

First normal form: one value per cell

A table is in first normal form (1NF) when:

  • every cell holds a single, atomic value,
  • there are no repeating groups of columns, and
  • each row is unique (the table has a primary key).

Here's an order table that breaks 1NF:

order_idcustomerbooks
5001Ana RuizDune (x1), Emma (x2)
5002Ben OkaforDune (x1)

The books cell crams several items, each with a quantity, into one string. You can't sum quantities, find every order containing Emma reliably, or ensure each book exists. A common "fix," columns book1, qty1, book2, qty2, book3, qty3, is a repeating group: it caps orders at three books and fills the table with NULLs.

The 1NF fix is one row per order per book:

order_idorder_datecustomer_idcustomer_nameisbntitleqty
50012026-03-027Ana Ruiz978-0441013593Dune1
50012026-03-027Ana Ruiz978-0141439587Emma2
50022026-03-049Ben Okafor978-0441013593Dune1

The key is now (order_id, isbn). The table is in 1NF, but obviously redundant: the order date and customer repeat on every line, and each title repeats on every sale. That's what 2NF and 3NF fix.

Step 2 of 14Practice · Spot the mistake

A designer claims this product table is in first normal form. Tap the two columns that break 1NF.

Step 3 of 14Compare

Breaking 1NF and fixing it

AspectBreaks 1NFFixed
List in a cellbooks = "Dune, Emma"One row per order and book
Repeating columnsphone1, phone2, phone3A child table with one row per phone
Duplicate rowsTwo identical rows, no keyA primary key makes every row unique

Step 4 of 14Learn

Second normal form: the whole key

A table is in second normal form (2NF) when it is in 1NF and every non-key column depends on the whole primary key, not just part of it. 2NF only matters for tables with a composite key; a table with a single-column key that is in 1NF is automatically in 2NF.

In the 1NF order table, the key is (order_id, isbn). Check each non-key column:

  • order_date, customer_id, customer_name depend on order_id alone: partial dependencies.
  • title depends on isbn alone: a partial dependency.
  • qty depends on both order_id and isbn: a full dependency. Good.

The fix is to move each group of partially dependent columns into its own table, keyed by the part they depend on:

  • orders(order_id, order_date, customer_id, customer_name)
  • book(isbn, title)
  • order_line(order_id, isbn, qty)

Now an order's date is stored once, not once per book, and a title is stored once, not once per sale. You can add a book that hasn't sold yet. And nothing is lost: joining the three tables on order_id and isbn reproduces the original rows exactly. This property, being able to rebuild the original data by joining, is called a lossless decomposition, and every normalization step must preserve it.

Step 5 of 14Practice · Choose one

A table has the composite key (student_id, course_code) and columns grade and student_email. Why is it not in 2NF?

Step 6 of 14Learn

Third normal form: nothing but the key

A table is in third normal form (3NF) when it is in 2NF and no non-key column depends on another non-key column. In other words, there are no transitive dependencies.

Look at the orders table from the 2NF step: orders(order_id, order_date, customer_id, customer_name). The key is order_id. But customer_name doesn't really describe the order; it describes the customer. The chain is order_id → customer_id → customer_name. Every order Ana places repeats her name, and if she changes it, every order row must change. That's a transitive dependency.

The fix follows the same pattern: move the dependent column into a table keyed by its determinant.

  • customer(customer_id, customer_name)
  • orders(order_id, order_date, customer_id)
  • book(isbn, title)
  • order_line(order_id, isbn, qty)

Each table now describes exactly one kind of thing. Each fact (a name, a title, a date, a quantity) is stored once. The anomalies from the start of the module are gone: you can add a customer with no orders, change a name in one place, and delete an order without losing the customer.

In everyday practice, "normalized" usually means 3NF. Most well-designed business databases are in 3NF or very close to it.

Step 7 of 14Practice · Put in order

Order the steps for normalizing a flat table up to 3NF.

Drag the items, or use the arrow buttons, to put them in order.

  1. Check that joining the new tables reproduces the original data
  2. Split multivalued cells and repeating groups into separate rows (1NF)
  3. Identify the primary key and the functional dependencies
  4. Move columns that depend on other non-key columns into their own tables (3NF)
  5. Move columns that depend on only part of a composite key into their own tables (2NF)

Step 8 of 14Practice · Work it out

A flat table with key (order_id, isbn) has these dependencies: order_id → order_date, customer_id; customer_id → customer_name, customer_email; isbn → title, price; and (order_id, isbn) → qty. How many tables does a 3NF design have?

Step 9 of 14Diagram

From flat table to 3NF

In the exercise you just did, each distinct determinant (order_id, customer_id, isbn and the full key) became the key of its own table.

From flat table to 3NFProcess diagram: Make cells atomic (1NF) → List the dependencies → Split off partial dependencies (2NF) → Split off transitive ones (3NF) → Check joins rebuild the original.Make cells atomic(1NF)List thedependenciesSplit off partialdependencies (2NF)Split off transitiveones (3NF)Check joins rebuildthe original

Tap a shape with to see more.

Make cells atomic (1NF)

Split lists into rows and give the table a key.

List the dependencies

For each column, ask what determines it.

Split off partial dependencies (2NF)

Columns that depend on part of the key move to a table keyed by that part.

Split off transitive ones (3NF)

Columns that depend on a non-key column move to a table keyed by it.

Check joins rebuild the original

A lossless decomposition loses no facts.

Step 10 of 14Note

Step 11 of 14Practice · True or false

A table whose primary key is a single column and that is in 1NF is automatically in 2NF.

Step 12 of 14Flashcards

Normal forms in one line each

Tap a card to flip it.

Step 13 of 14Practice · What would you do?

What would you do?

An employee table has columns employee_id (key), name, department_id, department_name and department_budget. What change brings it to 3NF?

Step 14 of 14Practice · Choose one

Which table is in third normal form? (Keys are listed first.)