Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: Performance & internals
Stage 5: Specialization

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.

  1. Why doesn't orders just store the customer's name?
  2. What condition do most joins use?
Show the answers
  1. The name would be duplicated per order; updates would miss copies and the data would drift. One fact, one place — orders point at it.
  2. 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.

Search the guide