Part 05 / Topic 1 of 9
Why data is split across tables
shopdb stores the customer's name once, in customers — orders carry only a customer_id. That is deliberate. If every order row repeated the name and email, then fixing one typo would mean updating many rows, and the copies would drift apart (Stage 3's normalization lesson makes this precise).
The price: no single table answers a real question. "Show orders with customer names" needs orders and customers, stitched by the key they share:
orders customers
order_id | customer_id | ... customer_id | first_name | ...
1 | 1 | ────► 1 | Asha
2 | 2 | ────► 2 | Ravi
A join is that stitching: combine rows from two tables wherever a condition — almost always foreign key = primary key — holds. Every join in this part is some variation on that one idea.
🧪 Quick quiz — answer from memory, then check.
- Why doesn't
ordersjust store the customer's name? - What condition do most joins use?
Show the answers
- The name would be duplicated per order; updates would miss copies and the data would drift. One fact, one place — orders point at it.
- Foreign key equals primary key:
orders.customer_id = customers.customer_id.
Done here? The practice set for Part 5 — 8 exercises with solutions — is on the part page.