In this article we give the information about normalization in a database design technique that organizes tables in a manner that reduce redundancy (useless) and dependency of data.
Normalization in Database:
- Normalization is a database design technique that organizes tables in a manner that reduce redundancy (useless) and dependency of data.
- To avoid insertion, update & deletion anomaly.
- Normalization divides larger tables into smaller table and link them using relationships. (Primary key and Foreign key)
Anomaly (Insertion, Update, Delete)
Anomaly: Something that is not according to standard or normal
Table Name: student
Roll_No | Name | Address | Dept |
1 | Rahul | Pune | BCA |
1 | Rahul | Pune | BA |
2 | Pranav | Satara | MBA |
3 | Geeta | Sangli | BCA |
3 | Geeta | Sangli | BA |
Insert:
Insert into student (Roll_No, Name, Addrress) values (4, ‘Amol’, ‘Satara’);
Result: student does not allow null values
Update:
Update student set dept=’BCA’ where Roll_No=1;
Result: Update two rows
Delete:
Delete from student where Roll_No=1;
Result: Delete two rows
Normalization Types:
Here are most commonly used normal forms:
- First Normal Form (1NF)
- Second Normal Form (2NF)
- Third Normal Form (3 NF)
- Boyce & Codd Normal Form (BCNF)
- Forth Normal Form (4NF)
- Fifth Normal Form (5NF)
First Normal Form (1NF)
As per the rule of first normal form,
- An attributes (Column) of a table cannot hold multiple values.
- It should hold only atomic (forming a single unit) values.
- Each record needs to be unique.
Atomic value: An atomic value is a value that cannot be divided.
Table Name: student
Roll_No | Name | Mobile_No | Dept |
1 | Rahul | 9986532147 | BCA |
2 | Amol | 9865326589, 9965832658 | BA |
3 | Pranav | 9789563211, 9856231458 | MBA |
4 | Geeta | 9963524789 | BCA |
5 | Jaya | 9856231458 | BA |
Above table, column mobile number there are two mobile numbers in rows two and three so there is not an atomic value.
After First Normalization
Table Name: student
Roll_No | Name | Mobile_No | Dept |
1 | Rahul | 9986532147 | BCA |
2 | Amol | 9865326589 | BA |
2 | Amol | 9965832658 | BA |
3 | Pranav | 9789563211 | MBA |
3 | Pranav | 9856231458 | MBA |
4 | Geeta | 9963524789 | BCA |
5 | Jaya | 9856231458 | BA |
Second normal form(2NF):-
- It should be in the first normal form.
- All non key attributes are fully functional dependent on the primary key. In simple words it should not have partial dependency
A table or relation is in 2nd normal form when it meets all the requirements of 1st normal form and all non-key attributes are completely dependent on the primary key.
Table Name: Employee
Emp_ID |
Qualification |
Age |
101 | BCA | 20 |
101 | MCA | 20 |
101 | MBA | 20 |
102 | BCom | 21 |
102 | MBA | 21 |
103 | MCA | 22 |
104 | MSW | 23 |
104 | MBA | 23 |
Composite Primary Key: Emp_ID + Qualification
Non Key Attribute: Age
Example:
Q. Find the age of employee where employee ID is 102
SQL> Select * from Employee where emp_id=102;
O/P:
102 BCom 21
102 MBA 21
here we get the two age values that is not in proper out put.
After Second Normalization
To make the table compiles with 2NF we can break it in two tables like this:
Here,
1st NF:
- It should hold only atomic values.
- Each record needs to be unique.
2nd NF:
- Non key attribute should be depend on single key (that is primary key)
Third Normal Form (3rd NF):
- It is in second normal form.
- There is no transitive functional dependency.
- A transitive functional dependency is when changing a non-key column, might clause any of the other non-key column to change.
Here,
Emp_ID-> Zip-> City that is City depend on zip and zip depend on Emp_ID
Emp_ID-> City City dependent on Emp_ID
City Indirectly depend on Emp_ID is called transitive functional dependency.
After Third Normalization;
Some More:
POP- Introduction to Programming Using ‘C’
OOP – Object Oriented Programming
DBMS – Database Management System
RDBMS – Relational Database Management System
Join Now: Data Warehousing and Data Mining