CodeBlanks Logo Icon CodeBlanks

Third normal form

Learn third normal form (3NF).

3NF

3NF is in 2NF with no transitive dependency. Non-key columns cannot depend on each other.

-- customers(id, city, postal_code, city_name)
-- city_name → city → id : geçişli bağımlılık

Move city_name to a cities table.

3NF — details

3NF removes transitive dependencies. In A → B → C, you move C to a separate table.

For example, if orders holds customer_id and customer_city, the city really depends on the customer, so it moves to the customers table.

Practice 3NF

Move city_name to a cities table to reach 3NF.

Starter code

query.sql
-- normalize to 3NF
CREATE TABLE

Sample solution

query.sql
CREATE TABLE cities (
  id INT PRIMARY KEY,
  name VARCHAR(50)
)

Expected output

Tablo oluşturuldu

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What does 3NF remove?

  • Partial dependency
  • Transitive dependency Correct answer
  • Repetition
  • NULLs

Explanation: 3NF removes transitive dependencies.

2 3NF dependency

Question
3NF: no transitive ____ allowed
Answer
3NF: no transitive dependency allowed

Explanation: 3NF allows no transitive dependency.

3 Third normal form: match the terms

Term Meaning
3NF transitive dependency
A→B→C chain
separate move
non-key independent

All lessons in Intermediate