Normalization is the process of structuring a relational database to reduce redundancy, dependency, and improve data integrity. It involves organizing data into multiple related tables using rules called normal forms.

Let’s walk through:


🎯 Goals of Normalization

  • Eliminate redundant data (e.g., storing the same data in multiple tables)
  • Ensure data dependencies make sense
  • Make insert, update, delete operations efficient and safe

βœ… First Normal Form (1NF)

🎯 Rule:

  • Each cell contains atomic (indivisible) values.
  • Each record must be unique.
  • No repeating groups or arrays.

❌ Bad Table (Not in 1NF):

StudentIDNameCourses
1AliceMath, Physics
2BobChemistry

Courses is a multi-valued field β†’ Not atomic.


βœ… 1NF Table (Atomic values):

Split into two tables:

Students

StudentIDName
1Alice
2Bob

Enrollments

StudentIDCourse
1Math
1Physics
2Chemistry

βœ… Second Normal Form (2NF)

🎯 Rule:

  • Must first satisfy 1NF
  • Remove partial dependencies (i.e., non-key columns depending on only part of a composite key)

❌ Bad Table (1NF but not 2NF):

StudentIDCourseInstructorDepartment
1MathDr. SmithMathematics
1PhysicsDr. NewtonPhysics
  • Composite key: (StudentID, Course)
  • Instructor, Department depend only on Course, not full key β†’ Partial dependency

βœ… 2NF Solution:

Split into:

Enrollments

StudentIDCourse
1Math
1Physics

Courses

CourseInstructorDepartment
MathDr. SmithMathematics
PhysicsDr. NewtonPhysics

Now all non-key fields fully depend on their primary key.


βœ… Third Normal Form (3NF)

🎯 Rule:

  • Must satisfy 2NF
  • No transitive dependencies (non-key depends on non-key)

❌ Bad Table (2NF but not 3NF):

EmployeeIDNameDeptIDDeptName
1AliceD01HR
2BobD02Finance
  • DeptName depends on DeptID, not on EmployeeID β†’ Transitive dependency

βœ… 3NF Solution:

Employees

EmployeeIDNameDeptID
1AliceD01
2BobD02

Departments

DeptIDDeptName
D01HR
D02Finance

βœ… Boyce-Codd Normal Form (BCNF)

🎯 Rule:

  • Stronger version of 3NF
  • For any dependency X β†’ Y, X must be a super key

Use when:

  • Multiple candidate keys exist
  • 3NF is not enough

πŸ“Š Summary Table

Normal FormRule Summary
1NFAtomic columns, unique rows
2NFNo partial dependency on composite keys
3NFNo transitive dependency
BCNFEvery determinant is a candidate key

πŸ› οΈ How to Normalize in Practice

  1. Start with one large table (denormalized)
  2. Identify repeating groups, move them into separate tables (1NF)
  3. Remove partial dependencies β†’ move data into separate tables (2NF)
  4. Eliminate transitive dependencies β†’ create foreign key relationships (3NF)
  5. Analyze candidate keys and apply BCNF if needed

πŸ” Denormalization (reverse process)

Sometimes, you denormalize for:

  • Reporting
  • Joins performance
  • Simplified queries

Use carefully, only when performance justifies it.


Pages: 1 2


Discover more from HintsToday

Subscribe to get the latest posts sent to your email.

Posted in

Leave a Reply

Discover more from HintsToday

Subscribe now to keep reading and get access to the full archive.

Continue reading