Third Normal Form (3NF): Eliminating Transitive Dependencies
Remove transitive dependencies so non-keys depend only on keys.
In plain words
Each fact should live in one place. If a column is really about something other than the row's key, move it to that thing's table.
Think of it like…
Writing a student's school address on every one of their exam papers. When the school moves, you have to correct every paper, and one missed paper means two "true" addresses. Store the address once, with the school.
Where you’ve seen it
orders(order_id, customer_id, customer_name, customer_city, amount): name and city depend on customer_id, not on order_id. Split it into orders(order_id, customer_id, amount) and customers(customer_id, name, city), and a city change touches one row.
Words you’ll hear
- Functional dependency
- A → B: knowing A determines B (customer_id determines customer_city).
- Transitive dependency
- Key → X → Y, where X isn't a key, so Y depends on the key only through X.
- Update anomaly
- The same fact stored in many rows gets changed in some but not others.
- Denormalisation
- Deliberately duplicating data for read performance, usually in analytics.
Visual diagram
Theory & example queries
Spotting a transitive dependency
For each non-key column, ask: "Is this a fact about the key, or about another column?" In orders, amount is a fact about the order; customer_city is a fact about the customer, which the order only refers to. That makes it transitive: order_id → customer_id → customer_city.
A well-known summary of the normal forms: every non-key column must depend on the key, the whole key (2NF), and nothing but the key (3NF). Typical 3NF violations are a zip code next to its city, a product's category name next to category_id, or an employee's department name next to department_id.
| id | name | city | |
|---|---|---|---|
| 1 | Maya | maya@example.com | Pune |
| 2 | Ravi | ravi@example.com | Delhi |
| 3 | Noor | noor@example.com | Mumbai |
| id | customer_id | status | amount | coupon_code |
|---|---|---|---|---|
| 101 | 1 | paid | 249 | NULL |
| 102 | 2 | paid | 120 | WELCOME10 |
| 103 | 1 | shipped | 89.5 | NULL |
CREATE TABLE customers ( id bigint PRIMARY KEY, name text, city text);CREATE TABLE orders ( id bigint PRIMARY KEY, customer_id bigint REFERENCES customers (id), amount numeric);PostgreSQL is the lesson baseline unless noted otherwise.
Identify the table or database object the statement will modify.
Normalized tables created
Note: Representative PostgreSQL command tags; both table names must be unused.
Key takeaway: If a column describes something other than the key, it belongs to that something's table.
Anomalies, and when to denormalise
Without 3NF you get three classic anomalies. Update: the city is stored on every order, so changes must hit every row. Insert: you can't record a new customer's city until they order. Delete: removing a customer's last order loses their details.
3NF is the normal target for transactional (OLTP) databases. Analytics warehouses often denormalise on purpose (star schemas, wide tables) because reads dominate and the data is loaded in controlled batches. Denormalise as a decision, not by accident.
| id | name | city | |
|---|---|---|---|
| 1 | Maya | maya@example.com | Pune |
| 2 | Ravi | ravi@example.com | Delhi |
| 3 | Noor | noor@example.com | Mumbai |
| id | customer_id | status | amount | coupon_code |
|---|---|---|---|---|
| 101 | 1 | paid | 249 | NULL |
| 102 | 2 | paid | 120 | WELCOME10 |
| 103 | 1 | shipped | 89.5 | NULL |
SELECT o.id, o.amount, c.cityFROM orders o JOIN customers c ON c.id = o.customer_id;PostgreSQL is the lesson baseline unless noted otherwise.
Calculate the selected expressions and return the requested output columns.
Orders with customer city3 sample rows
| id | amount | city |
|---|---|---|
| 501 | 2499 | Pune |
| 502 | 899 | Delhi |
| 503 | 1750 | Pune |
Note: Representative order and customer sample; the join retrieves city without storing it in orders.
The join replaces the duplicated column.
Key takeaway: Normalise transactional data; denormalise analytics deliberately.
How it works, step by step
Follow one practical SQL workflow from start to finish. Select any step or play through the flow.
Confirm the key
Identify the table's primary key and check it's already in 2NF: no column depends on just part of a composite key.
PRIMARY KEY (order_id)
When to use it & trade-offs
What it is
A table is in Third Normal Form (3NF) when it's in 2NF and no non-key column depends on another non-key column. In other words, every non-key column describes the key directly, not something else in the row. A dependency like order_id → customer_id → customer_city is *transitive*, and 3NF moves it into its own table.
Why it matters: Transitive dependencies store the same fact in many rows, so updates, inserts and deletes go wrong: change a customer's city and you must update every order row, or the data contradicts itself. Normalisation questions are standard in backend and database interviews.
When to reach for it
- Designing the schema of a transactional application
- Reviewing a table that repeats the same value across many rows
- Explaining update, insert and delete anomalies
When to avoid or be careful
- Copying descriptive columns (names, cities) into every child table
- Normalising analytics tables so far that every report needs ten joins
- Storing derived values (order totals) without a plan to keep them in sync
2NF vs 3NF vs denormalised
Strengths: Removes one class of duplication.
Watch out: Transitive dependencies can still duplicate facts.
Strengths: Each fact is stored once, so updates are simple and consistent.
Watch out: Reads need joins.
Strengths: Fast reads with few joins.
Watch out: Duplicated data must be kept in sync by the loading process.
Interview signals & numbers to know
When this topic comes up
- “Normalise this table”
- “What is a transitive dependency?”
- The same value repeated on many rows
- Update, insert and delete anomalies
- “When would you denormalise?”
Benchmarks & rules of thumb
- 1NF
- atomic values, no repeating groups
- 2NF
- no partial dependency on part of the key
- 3NF
- no dependency between non-key columns
Common mistakes & follow-ups
Common interview mistakes
- Calling a table normalised because it has a primary key, while it still repeats customer details on every order.
- Confusing 2NF (partial dependency on a composite key) with 3NF (dependency between non-key columns).
- Normalising without moving the data carefully, so conflicting values for the same customer are silently lost.
Likely interviewer follow-ups
- What's the difference between 2NF and 3NF?
- What is BCNF, and when is a table in 3NF but not BCNF?
- When would you deliberately denormalise, and what do you have to manage?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Third Normal Form (3NF): Eliminating Transitive Dependencies with hands-on SQL practice and interview Q&A.