Posted on: March 12, 2025 Posted by: rahulgite Comments: 0

1. Normalization

Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity.

Objectives of Normalization:

  • Minimize data duplication
  • Ensure data consistency
  • Simplify data maintenance
  • Improve data integrity

Forms of Normalization:

  1. First Normal Form (1NF):
    • Ensure each column contains atomic (indivisible) values.
    • Each column must contain unique data of a specific type.

Example:

Before 1NF:

StudentIDNameSubjects
1John DoeMath, Science

What We Did:

  1. Split the multi-valued “Subjects” column into separate rows.

After 1NF:

StudentIDNameSubject
1John DoeMath
1John DoeScience
  1. Second Normal Form (2NF):
    • Must meet 1NF requirements.
    • Ensure all non-key attributes are fully functionally dependent on the primary key.

Example:

Before 2NF:

OrderIDProductIDProductName
1101Laptop

What We Did:

  1. Split into two tables to separate product information.

After 2NF:

Orders Table:

OrderIDProductID
1101

Products Table:

ProductIDProductName
101Laptop
  1. Third Normal Form (3NF):
    • Must meet 2NF requirements.
    • Ensure no transitive dependency exists (i.e., non-key columns should not depend on other non-key columns).

Example:

Before 3NF:

EmployeeIDDepartmentIDDepartmentName
1101Sales

What We Did:

  1. Moved “DepartmentName” to a new table to remove transitive dependency.

After 3NF:

Employees Table:

EmployeeIDDepartmentID
1101

Departments Table:

DepartmentIDDepartmentName
101Sales
  1. Boyce-Codd Normal Form (BCNF):
    • A stricter version of 3NF.
    • Every determinant must be a candidate key.

Example:

Before BCNF:

ProfessorIDDepartmentSubject
1CSDatabase
1CSAlgorithms

What We Did:

  1. Decomposed into two tables to ensure every determinant is a candidate key.

After BCNF:

Professor_Department Table:

ProfessorIDDepartment
1CS

Professor_Subject Table:

ProfessorIDSubject
1Database
1Algorithms
  1. Fourth Normal Form (4NF):
    • Must meet BCNF requirements.
    • Eliminate multi-valued dependencies.

Example:

Before 4NF:

StudentIDHobbySkill
1PaintingJava
1PaintingPython

What We Did:

  1. Split multi-valued attributes into separate tables.

After 4NF:

Student_Hobby Table:

StudentIDHobby
1Painting

Student_Skill Table:

StudentIDSkill
1Java
1Python

2. Denormalization

Denormalization is the process of combining normalized tables to improve read performance at the cost of increased redundancy.

Example of Denormalization:

Before Denormalization:

Orders Table:

OrderIDCustomerID
1101

Customers Table:

CustomerIDCustomerName
101John Doe

What We Did:

  • Merged “Customers” data into the “Orders” table to reduce joins.

After Denormalization:

OrderIDCustomerIDCustomerName
1101John Doe

Normalization vs. Denormalization:

FeatureNormalizationDenormalization
PurposeReduce redundancy, ensure integrityImprove read performance, reduce joins
Data IntegrityHigh (fewer inconsistencies)Lower (due to duplication)
Query PerformanceSlower (requires joins)Faster (fewer joins)
Storage EfficiencyUses less storageUses more storage
ComplexityHigher (more tables, more joins)Simpler (fewer tables, easier queries)
MaintenanceEasier (less redundancy)Harder (due to data duplication)

Leave a Comment