Normalization in SQL for Freshers: Easy Guide with Examples

Normalization is the process of organizing data in a database so that:

  1. Data is stored efficiently (no repetition).
  2. Data is consistent (no errors or conflicts).
  3. Easy to update, insert, or delete data without issues.

Think of it like arranging your room:

  • Don’t keep the same book in 5 places (redundancy).
  • Keep things in proper boxes (tables) so you can find them easily.

Why Do We Normalize?

  • To remove duplicate data
  • To avoid data anomalies (like mistakes when updating or deleting)
  • To make database maintenance easy

Types of Normalization (Normal Forms)

Normalization is done in steps called Normal Forms (NF).

Normalization in SQL for Freshers: Easy Guide with Examples

First Normal Form (1NF)

  • Each column should have atomic (single) values.
  • No repeating groups or arrays in a column.

Example:

Bad table:

student_idnamesubjects
1RameshMaths, Science
2PriyaArts, Maths

1NF Table:

student_idnamesubject
1RameshMaths
1RameshScience
2PriyaArts
2PriyaMaths
  • Each column has only one value now.

Second Normal Form (2NF)

  • Already in 1NF.
  • Every column must depend fully on the primary key (no partial dependency).

Example:

student_idsubjectteacher_name
  • If teacher_name depends only on subject, not student_id, it’s partial dependency → violates 2NF.

Fix (2NF):

  • Table 1: Student-Subjects
    | student_id | subject |
    |————|———|
    | 1 | Maths |
  • Table 2: Subject-Teacher
    | subject | teacher_name |
    |———|————–|
    | Maths | Mr. Sharma |

Third Normal Form (3NF)

  • Already in 2NF.
  • No transitive dependency: Non-primary key columns should not depend on other non-primary columns.

Example:

student_iddept_iddept_name
  • dept_name depends on dept_id, not student_id → violates 3NF.

Fix (3NF):

  • Table 1: Students
    | student_id | dept_id |
    |————|——–|
  • Table 2: Departments
    | dept_id | dept_name |
    |———|———–|

Quick Summary Table

Normal FormRuleExample Fix
1NFEach column has atomic valueSplit multiple subjects into rows
2NFNo partial dependency on part of primary keyMove teacher info to separate table
3NFNo transitive dependencyMove department name to another table

Real-Life Analogy

  • 1NF → Keep one book per shelf slot, no stacking.
  • 2NF → Don’t write teacher’s name on each student’s book, keep a separate teacher list.
  • 3NF → Don’t write department name in every student’s record, keep a separate department table.

Super Simple Memory Trick

Normalization = Organizing your database neatly

  • 1NF → One value per column
  • 2NF → Every column depends fully on primary key
  • 3NF → No column depends on another non-key column