Normalization in DBMS


Normalization in databases is a process used to organize data to reduce redundancy and improve data integrity. The main goal is to divide a database into two or more tables and define relationships between them, ensuring that data is stored logically and consistently.

Normalization typically involves several stages, known as normal forms, each with specific rules to follow. Let’s discuss the primary normal forms along with examples:

1. First Normal Form (1NF)

A table is in 1NF if:

  • All columns contain atomic (indivisible) values.
  • Each column contains values of a single type.
  • Each column has a unique name.
  • The order in which data is stored does not matter.

Example: Before 1NF:

StudentIDNameCourses
1AliceMath, English
2BobScience, History

After 1NF:

StudentIDNameCourse
1AliceMath
1AliceEnglish
2BobScience
2BobHistory

2. Second Normal Form (2NF)

A table is in 2NF if:

  • It is in 1NF.
  • All non-key attributes are fully dependent on the primary key (i.e., no partial dependency).

Example: Before 2NF:

StudentIDCourseIDGrade
1101A
1102B

In this example, we assume that StudentID and CourseID together form the primary key.

After 2NF:

StudentIDName
1Alice
2Bob
CourseIDCourse
101Math
102English
StudentIDCourseIDGrade
1101A
1102B

3. Third Normal Form (3NF)

A table is in 3NF if:

  • It is in 2NF.
  • All the attributes are functionally dependent only on the primary key (i.e., no transitive dependency).

Example: Before 3NF:

StudentIDCourseIDGradeInstructor
1101ADr. Smith
1102BDr. Johnson

After 3NF:

StudentIDName
1Alice
2Bob
CourseIDCourse
101Math
102English
InstructorIDInstructor
1Dr. Smith
2Dr. Johnson
StudentIDCourseIDGrade
1101A
1102B
CourseIDInstructorID
1011
1022

4. Boyce-Codd Normal Form (BCNF)

A table is in BCNF if:

  • It is in 3NF.
  • For every functional dependency (X → Y), X should be a super key.

Example: Before BCNF:

StudentIDCourseIDInstructorIDInstructorName
11011Dr. Smith
11022Dr. Johnson

If an InstructorID is uniquely assigned to an InstructorName, then the above table would not satisfy BCNF as InstructorID should be a candidate key.

After BCNF:

StudentIDName
1Alice
2Bob
CourseIDCourse
101Math
102English
InstructorIDInstructor
1Dr. Smith
2Dr. Johnson
StudentIDCourseIDGrade
1101A
1102B
CourseIDInstructorID
1011
1022

5. Fourth Normal Form (4NF)

A table is in 4NF if:

  • It is in BCNF.
  • It has no multi-valued dependencies.

Example: Consider a situation where a student can have multiple projects and multiple advisors independently.

Before 4NF:

StudentIDProjectAdvisor
1MathDr. Smith
1ScienceDr. Jones
1MathDr. Brown

After 4NF:

StudentIDProject
1Math
1Science
StudentIDAdvisor
1Dr. Smith
1Dr. Jones
1Dr. Brown

These normal forms provide a framework for organizing data and ensure that the database is free from unnecessary redundancies and inconsistencies. As the normal forms progress from 1NF to 4NF (and beyond), they impose more rigorous requirements.

References

  1. Description of the database normalization basics
  2. Database normalization – Wikipedia
  3. Overview of Data, Database, DBMS, and RDBMS

Similar Posts

About the Author

Atul Rai
I love sharing my experiments and ideas with everyone by writing articles on the latest technological trends. Read all published posts by Atul Rai.