Normalization in Database.
What is normalisation in simple terms??
The process of organising data into columns and tables such as to reduce redundancy in the data is called normalisation. And to avoid insert, delete, and update anomalies.
From ☝ answer many of you know about redundancy but not anomalies,
So what is a anomaly?
Anomalies are problems that can occur in Poorly planned, un-normalised databases where all the data is stored in one table (a flat-file database). There are 3 types of anomalies
- insert anomaly
- delete anomaly
- update anomaly
I will explain the above with a simple example instead of explaining them with formal defnitions.
Consider the below table.
From the above table :
- Redundancy:When ever i add a student of cse department, the information about the department(i.e department name, hod and phone number) is repeating as you can see in above table. This redundancy should be reduced when you normalize the database.
- Insert anomaly: If i want to add new department without any students i can't do that because here the student id is primary key.
- Delete anomaly: If i remove student s2 then information about EC department will be lost.
- Update anomaly: If i want to update phone number of certain department then i have to change it in every row which is inefficient.
So Normalised Form of above tables is as shown below:
Comments
Post a Comment