Chapter 5 of 12
Course Progress0 of 12 completed (0%)

SQL & Relational Database Mastery · Chapter 5 · ~15 min · Intermediate

Database Design & Normalization: 1NF to 3NF

Master entity relationship modeling, eliminate insert, update, and delete anomalies, and transform chaotic spreadsheets into pristine 3NF relational schemas.

  • Model real-world systems with 1:1, 1:N, and N:M entity relationships using bridge tables
  • Eliminate multivalued attributes and repeating column groups to enforce First Normal Form (1NF)
  • Remove partial key dependencies on composite primary keys to achieve Second Normal Form (2NF)
  • Purge transitive dependencies (non-key columns determining non-key columns) for Third Normal Form (3NF)

Database Design & Normalization: 1NF to 3NF: learn it visually

Model relational entities, eliminate data anomalies, and master normal forms from atomic 1NF to transitive 3NF.

Database Design & Normalization: 1NF to 3NFModel relational entities, eliminate data anomalies, and master normal forms from atomic 1NF to transitive 3NF.UNDERSTANDDatabase DesignFOLLOW THE FLOWNormalizationAPPLY IT1NF 3NFDatabase Design & Normalization: 1NF to 3NFModel relational entities, eliminate data anomalies, and master normal forms from atomic 1NF to transitive 3NF.UNDERSTANDDatabase DesignFOLLOW THE FLOWNormalizationAPPLY IT1NF 3NF

1Intuition: From Spreadsheets to Relational Entities

Every software engineer has encountered a single giant spreadsheet pretending to be a database. When all data is crammed into one flat table, anomalies multiply exponentially: modifying an employee's title requires hundreds of row updates, deleting an obsolete project accidentally wipes out client records, and inserting a new department requires inventing dummy employees.

Relational database normalization is the mathematical procedure (developed by Edgar F. Codd) for organizing fields and tables to minimize redundancy and protect data integrity.

One-to-One (1:1)

A user has exactly one security profile. Placed in separate tables when attributes are accessed infrequently or carry strict access permissions.

One-to-Many (1:N)

One department contains many employees. Modelled with a Foreign Key on the child table pointing to the parent's Primary Key.

Many-to-Many (N:M)

Students enroll in multiple courses; courses enroll multiple students. Requires an intermediary junction / bridge table with a composite primary key.

Concept Check

A table stores employee certifications as 'AWS, GCP, CKA' in a text column. Which normal form is immediately violated?

2Architecture: 1NF, 2NF, and 3NF Step by Step

Normalization progresses through progressive stages. Each normal form builds strictly on the previous one: you cannot achieve 2NF without first satisfying 1NF.

Wrong idea: Storing comma-delimited lists in a single column

id: 101 | skills: "Python, SQL, Docker"
❌ Non-atomic: Violates 1NF; cannot index or join on individual skills

Saving 'Python,SQL,Docker' in a single tags column. Searching for a specific tag requires expensive wildcard scans (LIKE '%SQL%'), indexing is crippled, and aggregating tag statistics requires slow string splitting.

Real system: 1NF requires scalar atomic values with unique identity

[dev_id: 101, skill: 'Python'], [dev_id: 101, skill: 'SQL']
✅ First Normal Form: Atomic cells + composite PK (dev_id, skill)

Each table cell contains exactly one atomic value. Multivalued attributes are moved to dedicated rows or a separate bridge table, allowing foreign keys and B-Tree indexes to function at peak speed.

-- The Canonical Normalization Rule of Thumb:
-- "Every non-key attribute must provide a fact about the key,
--  the whole key (2NF), and nothing but the key (3NF), so help me Codd."

-- 1. PARENT ENTITY: Authors
CREATE TABLE authors (
    author_id INT PRIMARY KEY,
    author_name TEXT NOT NULL,
    country TEXT NOT NULL
);

-- 2. PARENT ENTITY: Publishers
CREATE TABLE publishers (
    publisher_id INT PRIMARY KEY,
    publisher_name TEXT NOT NULL
);

-- 3. CHILD ENTITY: Books (3NF Clean)
CREATE TABLE books (
    isbn VARCHAR(13) PRIMARY KEY,
    title TEXT NOT NULL,
    price DECIMAL(10, 2) NOT NULL,
    author_id INT REFERENCES authors(author_id),
    publisher_id INT REFERENCES publishers(publisher_id)
);
Concept Check

In an order_details table with composite primary key (order_id, product_id), the column 'product_category' depends solely on 'product_id'. What type of dependency is this, and what normal form does it violate?

3Interactive Visual: The Normalization Playground & Anomaly Tester

Explore how database tables evolve from unnormalized spreadsheets up through 3NF. Test the anomaly buttons to see first-hand why partial and transitive dependencies cause catastrophic production bugs.

Interactive Normalization Ladder & Anomaly Simulator

Current: unnormalized
Relational Architecture View1 monolithic table with repeated columns & non-atomic lists
order_idcustomeritems_list (multivalued)item_pricessupplier_namesupplier_city
1001Alice Chen"Laptop, Mouse, Bag""1200, 25, 45"TechCorpSan Jose
1002Bob Ross"Canvas, Brush""30, 15"ArtSupply CoDenver
Concept Check

A table 'employees' has primary key 'emp_id' and columns 'department_id' and 'department_head'. Why does this violate 3NF?

4Bug Hunt: Decompose Monolithic Enrollments into 3NF

The university registration office is suffering from frequent data loss and update conflicts because all student and course data was created inside a single unnormalized table. Refactor the schema into three clean 3NF tables.

SQL Bug Hunt · 3NF Schema Normalization
SQL

🎯 Find and fix the bugs in the code above, then press Run & verify to test your solution.

Need a hint?

• Create table students with student_id INT PRIMARY KEY.

• Create table courses with course_id INT PRIMARY KEY.

• Create bridge table enrollments with composite PRIMARY KEY (student_id, course_id).

Concept Check

When would a senior database architect intentionally choose to denormalize a 3NF schema in production?

5Recap & Entity Design Checklist

  • 1NF (Atomicity): Atomic scalar values, unique row identity (Primary Key), and zero comma-delimited or repeating columns.
  • 2NF (No Partial Key Dependencies): Every non-key column must depend on the entire composite primary key, not just a portion of it.
  • 3NF (No Transitive Dependencies): Non-key columns cannot depend on other non-key columns. Decompose intermediate relationships into dedicated entities.
  • Boyce-Codd (BCNF): Every determinant must be a candidate key.
  • OLTP vs OLAP Trade-off: High-throughput transactional systems (OLTP) rely on 3NF to prevent lock contention and update anomalies; analytical systems (OLAP/Star Schema) selectively denormalize for blazing query performance.

Ready for Chapter 6 (Subqueries & Common Table Expressions)? Mark as complete:

Enjoying this free lesson? Your support helps us build more free animated chapters.

Support Us