Normalization is a process or a database design method to achieve the goal of efficiently organizing data in a database.
There are two main objectives of database normalization:
1. To eliminate duplicate data
2. To ensure that the data stored in a table have some relationship.
The benefit of normalization is that it reduces the size of the database and ensures that data stored in some logical manner.
The Normal Forms
There are certain guidelines through which a database can be tested that it is normalized or not. These are called Normal Forms.
Here I am explaining most common Normal Forms which are;
First normal form
Second normal form
Third normal form
Fourth normal form
Boyce-Codd normal form
First Normal Form (1NF)
First normal form has following guidelines;
1. The table should not contain duplicate rows or columns having same name.
2. For each group of related data there should be a different table and there should be a column or a group of columns through which a row can be uniquely identified. This column or group of column is called
Primary Key.
Second Normal Form (2NF)
Second normal form has following set of rules;
1. The table must meet the rules of 1NF.
2. If there should be any subset of data that is present in multiple rows then create a different table for them
3. There must have a relationship between these two tables through the foreign keys.
Third Normal Form (3NF)
Third normal form has following guidelines;
1. It should meet all the requirements of 2NF.
2. There will be no columns that dont depend on the primary key.
Fourth Normal Form (4NF)
Fourth normal form has following set of rules;
1. The table should be in 3NF.
2. There should be no multi-valued dependencies.
Boyce-Codd normal form(BCNF)
The Boyce-Codd normal form is another popular normal form which has following criteria;
1. The table must be in 3NF.
2. All the functional dependencies must have primary key associated with it.
e.g. Consider the table (Student_id primary key, name, address) and if there exist a relation name => address then its not in BCNF. To comply it with BCNF break it into two tables (Student_id primary key, name) and (Student_id primary key, address)