First normal form
🏠The everyday picture
A register where one box says "English, Hindi, Maths" can't be sorted or counted by subject. Each subject needs its own line.
📘What it really is
- A table is in first normal form (1NF) when:
- each column holds one value (no lists like
"Pen, Notebook, Bag"); - there are no repeating groups of columns (
phone1,phone2,phone3); -
each row is unique (it has a primary key).
-
Fixing violations:
- a list in a column becomes rows in another table (
order_itemsinstead ofproduct_names); - repeating columns become rows in a child table (
customer_phoneswith one phone per row), or you decide only one is really needed. -
Why it matters: you can't search, count, join or constrain values hidden inside lists. "How many orders included pens?" becomes text-matching guesswork.
-
PostgreSQL's array and
jsonbcolumns can hold lists; use them for genuinely self-contained data (like a list of tags you only ever show), not for things you'll query, count or link.
🖱️Try it
Take the orders spreadsheet design from Lesson 1 and bring it to 1NF: split the product lists into an items table, one row per product in each order.
✅Quick check
Is a phone_numbers column containing "98xxx, 97xxx" in 1NF?
Show the answer
No. Each column must hold a single value; put phone numbers in rows of their own.
What's wrong with phone1, phone2 and phone3 columns?
Show the answer
A repeating group: it limits how many you can store and makes searching awkward. Use a separate table.
