- Normalization is the process of organizing the data in the database. It is used to reduce redundancy from a relation or set of relations.
- It is also used to eliminate the abnormalities of Insertion, Update, and Deletion.
- Normalization divides the larger table into the smaller table and links them using relationships.
Here are type of normal forms:
- First normal form(1NF)
- Second normal form(2NF)
- Third normal form(3NF)
- Boyce & Codd normal form (BCNF)
Normal Form | Description |
---|---|
1NF | A relation is in 1NF if it contains an atomic value (not having multiple-valued attributes). |
2NF | A relation will be in 2NF if it is in 1NF and all non-key attributes are fully functional dependent on the primary key. |
3NF | A relation will be in 3NF if it is in 2NF and no transition dependency exists. |
4NF /BCNF | A relation will be in 4NF if it is in Boyce Codd normal form and has no multi-valued dependency. |
Now ,we understand each of normal form with example
First normal form (1NF)
As per the rule of first normal form, an attribute (column) of a table cannot hold multiple values. It should hold only atomic values.
Example: Suppose a College wants to store the names and contact details of its student. It creates a table that looks like this:
Stud_id | Stud_name | Stud_address | Stud_mobile |
101 | Mansi | New Delhi | 8912314353 |
102 | Sachin | Kanpur | 88990001222 76452343234 |
103 | Komal | Mumbai | 77345436544 94653565355 |
104 | Aryan | Bangalore | 343123450987 |
Two Student (Komal & Sachin) are having two mobile numbers so the college stored them in the same field as you can see in the table above.
This table is not in 1NF as the rule says “each attribute of a table must have atomic (single) values”, the emp_mobile values for employees Sachin & Komal violates that rule.
To make the table complies with 1NF we should have the data like this:
Stud_id | Stud_name | Stud_address | Stud_mobile |
101 | Mansi | New Delhi | 8912314353 |
102 | Sachin | Kanpur | 88990001222 |
102 | Sachin | Kanpur | 76452343234 |
103 | Komal | Mumbai | 77345436544 |
103 | Komal | Mumbai | 94653565355 |
104 | Aryan | Bangalore | 343123450987 |
Here in above table (Stud_id and Stud_mobile) combined together to act as PRIMARY KEY, which is an example of Composite Primary key.
To know about more