Database.Beginner.Normalization.1NF.2NF.3NF

First Normal Form (1NF)

Goal:

  • Eliminate repeating groups.
  • Make sure each field contains atomic (indivisible) values.

A table NOT in 1NF:

student_idnamecourses
1AliceMath, History
2BobMath

Problem:

  • courses has multiple values in one column — this is not atomic.

Fix — Table in 1NF:

Break it into one row per course:

student_idnamecourse
1AliceMath
1AliceHistory
2BobMath

✅ Each field contains atomic values.
✅ No multi-valued columns.

Second Normal Form (2NF)

Goal:

  • Be in 1NF AND
  • Eliminate partial dependencies (no attribute should depend only on part of a composite primary key).

A table in 1NF but NOT in 2NF:

Assume the primary key is (student_id, course).

student_idcoursestudent_name
1MathAlice
1HistoryAlice
2MathBob

Problem:

  • student_name depends only on student_id, not on the whole key (student_id, course).
  • This is a partial dependency.

Fix — Table in 2NF:

Split into two tables:

Students

student_idstudent_name
1Alice
2Bob

Enrollments

student_idcourse
1Math
1History
2Math

✅ Now every non-key column depends on the whole primary key.

Third Normal Form (3NF)

Goal:

  • Be in 2NF AND
  • Eliminate transitive dependencies (non-key columns must depend only on the primary key, not on other non-key columns).

A table in 2NF but NOT in 3NF:

student_idstudent_namestudent_zipcodezipcode_city
1Alice12345New York
2Bob67890Los Angeles

Problem:

  • zipcode_city depends on student_zipcode, not directly on student_id.
  • This is a transitive dependency: student_id → student_zipcode → zipcode_city.

Fix — Table in 3NF:

Split into two tables:

Students

student_idstudent_namestudent_zipcode
1Alice12345
2Bob67890

Zipcodes

student_zipcodezipcode_city
12345New York
67890Los Angeles

✅ Now, all non-key columns depend only on the primary key.


Summary Table

Normal FormWhat It FixesRequirement
1NFRepeating groups, multivalued columnsAtomic values (no lists or sets inside fields).
2NFPartial dependenciesNo non-key column depends on part of a composite key.
3NFTransitive dependenciesNo non-key column depends on another non-key column.

🎯 In Simple Words:

  • 1NF: One value per cell.
  • 2NF: No partial key dependency.
  • 3NF: No indirect dependency.
This entry was posted in Без рубрики. Bookmark the permalink.