2. Designing Tables & Combining Data

Database Normalization (1NF, 2NF & 3NF Made Simple)

Learn how to organize tables cleanly without duplicate data bugs: understand 1st, 2nd, and 3rd Normal Form in plain English using real before-and-after table examples.

4 min readUpdated 2026-11-29
In This Lesson
  • Spot duplicate-data traps in poorly designed tables before writing code
  • Apply 1st, 2nd, and 3rd Normal Form (1NF–3NF) in plain English
  • Split messy flat spreadsheets into clean, linked relational tables

Imagine starting an online store and saving every order inside one giant spreadsheet where every single row repeats the customer's name, city, and purchased items:

order_idcustomer_namecustomer_cityitems
1Alex RiveraChicagoKeyboard, Lamp
2Alex RiveraChicagoPython Book

At 10 rows, that spreadsheet feels convenient. At 10,000 rows, it becomes a maintenance nightmare. What happens when Alex moves from Chicago to Seattle? You have to hunt down and update every past order row—and if a single row fails to update, your database contradicts itself. Worse, trying to count how many Lamps were sold means parsing messy comma-separated text.

Database normalization sounds academic, but it is really just a practical three-part checklist that stops duplicate-data bugs by ensuring every fact lives in one place.

Normalization: Eliminating Duplicate Data with Foreign Keys

Before (Denormalized / Repeated)

order=1 | Maya | maya@ex.com | Keyboard
order=2 | Maya | maya@ex.com | USB Hub

Email & name duplicated on every row—easy to go out of sync.

After (Normalized 3NF Tables)

customers: id=2, Maya, maya@ex.com
orders: id=1, customer_id=2 (FK)
orders: id=2, customer_id=2 (FK)

Splitting repeated customer/course info into separate tables prevents update anomalies: changing Maya's email happens in ONE row instead of 50 order rows.

First Normal Form (1NF): One Value Per Cell

Look closely at Order #1 above: the items column squeezes two different products into a single cell ("Keyboard, Lamp"). You cannot easily sort by product, join against an inventory price list, or calculate how many Keyboards were ordered last month.

The 1NF Rule: Keep every cell atomic—store one value per cell, never comma-separated lists. Give each purchased item its own row inside an order_items table:

order_iditem_name
1Keyboard
1Lamp
2Python Book

Notice how clean filtering and counting immediately become once each cell holds a single value.

Second Normal Form (2NF): Belong to the Whole Key

Suppose our order_items table uses a combined primary key of (order_id, product_id) and stores both quantity and product_price:

order_idproduct_idquantityproduct_name
11012Mechanical Keyboard
21011Mechanical Keyboard

Look at what depends on what: quantity genuinely depends on both which order and which product ((order_id, product_id)). However, product_name depends only on product_id—it does not care which order it sits on! Repeating "Mechanical Keyboard" across thousands of order lines wastes space and causes drift if the product is renamed.

The 2NF Rule: Every non-key column must depend on the entire primary key, not just half of it. Move product attributes (product_name, unit_price) into their own products table, and keep only product_id and quantity inside order_items.

Third Normal Form (3NF): No Indirect Side Dependencies

Now imagine an employees table that tracks which department someone works in along with the department's shared office phone number:

employee_idfull_namedepartment_iddepartment_phone
11Maya Chen4555-0140
12Omar Farooq4555-0140

Here, department_phone describes the department, not the individual employee. It sneaked into employees indirectly via department_id. If Engineering gets a new phone line, you would have to update dozens of employee rows instead of one.

The 3NF Rule: A non-key column should never describe another non-key column. Move department_phone into a departments table so changing it edits exactly one row.

The Classic Golden Rule of 1NF, 2NF, 3NF

Every non-key column in a table must describe the key (1NF), the whole key (2NF), and nothing but the key (3NF)!

Try It Yourself: Querying Normalized 3NF Tables

Our live sample database splits customers, orders, order_items, and products cleanly—letting you join them together without any duplicated customer names inside order_items:

SQL (SQLite)Live SQL: Joining Normalized E-Commerce Tables
Output

Click “Run Code” to execute this snippet right in your browser.

Quick Checkpoints

Check Your Understanding

Which normalization rule does storing 'Python, SQL, Git' inside a single skills text cell violate?