Normal Form

Normalization refers to the process of organizing the attributes and tables of a relational database to minimize redundancy and dependency.

A Normal Form is a set of guidelines or rules that define how data should be organized within tables to minimize redundancy and dependency, thereby reducing the likelihood of data anomalies.

Data anomalies are inconsistencies or errors that can occur in a database when it is not properly normalized.

There are many types of normal forms, and some of the normal forms that I have learned are:

  1. First and Second Normal Form
  2. Third Normal Form
  3. Boyce-Codd Normal Form (BCNF)
  4. Fourth Normal Form.

1. First Normal Form and Second Normal Form

First Normal Form

Second Normal Form.

2. Third Normal Form

A table is said to be in the Third Normal Form when,

  1. It satisfies the First Normal Form and the Second Normal form.
  2. And, it doesn’t have Transitive Dependency.

Transitive dependency ?

Example

Let’s say we have a table called Employee with attributes (Employee_ID, Employee_Name, Department, Manager). Here, Employee_ID is the primary key, and Manager represents the manager of each employee.

Employee_ID Employee_Name Department Manager
1 Chimi IT Sonam
2 Sonam HR Rinchen
3 Rinchen Finance Tshering

To solve transitive dependency

  1. Decomposed Tables:

Employee:

Employee_ID Employee_Name
1 Chimi
2 Sonam
3 Rinchen

Department:

Department Manager
IT Sonam
HR Rinchen
Finance Tshering

3. Boyce-Codd Normal Form (BCNF)

Functional dependency ?

A functional dependency in a database refers to a relationship between two attributes in a relation (or table) such that one attribute’s value uniquely determines the value of another attribute. It doesn’t necessarily have to be between a primary key and a non-key attribute.

Example of BCNF

EmployeeID Name Department
1 Nidup HR
2 Bob IT
3 Wangmo HR

In this case, EmployeeID serves as the primary key, and Name is functionally dependent on EmployeeID, because given an EmployeeID, there is only one corresponding Name.

However, Department is not functionally dependent on EmployeeID, as multiple employees can belong to the same department.

Condition Definition
If a relational schema is in BCNF Then all redundancy based on functional dependencies should be removed.
A table is in BCNF If every functional dependency X → Y, where X is the superkey of the table.

4. Fourth Normal Form

Multi-Valued Dependency ?

bike_model mani_year colour
R15 2022 blck
R15 2022 red
bmw 2018 yellow
bmw 2019 golden

Decomposed Tables:

Table 1: bike_model and mani_year

bike_model mani_year
R15 2022
R15 2022
bmw 2018
bmw 2019

Table 2: bike_model and colour

bike_model colour
R15 black
R15 red
bmw yellow
bmw golden

We can split the original table into two tables to remove the multi-valued dependency between bike_model and mani_year. Now each table represents a single-valued dependency, ensuring that the database is normalized.