Normalization in DBMS
Normalization in DBMS
Update anomalies − If data items are scattered and are not linked to each other properly, then it could lead to
strange situations. For example, when we try to update one data item having its copies scattered over several
places, a few instances get updated properly while a few others are left with old values. Such instances leave the
database in an inconsistent state.
Deletion anomalies − We tried to delete a record, but parts of it was left undeleted because of unawareness, the
data is also saved somewhere else.
Insert anomalies − We tried to insert data in a record that does not exist at all.
Normalization is a method to remove all these anomalies and bring the database to a consistent state.
Anomalies in DBMS cont….
The above table is not normalized. We will see the problems that we face when a table is not normalized.
Types of normalization
Here are the most commonly used normal forms:
• First normal form(1NF)
• Second normal form(2NF)
• Third normal form(3NF)
First normal form (1NF)
This table has a composite primary key [Customer ID, Store ID]. The non prime attribute is
[Purchase Location]. In this case, [Purchase Location] only depends on [Store ID], which is
only part of the primary key. Therefore, this table does not satisfy second normal form.
For a table to be in the third normal form, It should be in the Second Normal form.
With exam_name and total_marks added to our Score table, it saves more data now. Primary
key for our Score table is a composite key, which means it's made up of two attributes or
columns → student_id + subject_id. Our new column exam_name depends on both student and
subject.And what about our second new column total_marks? Does it depend on our Score
table's primary key?
Well, the column total_marks depends on exam_name as with exam type the total score
changesBut, exam_name is just another column in the score table. It is not a primary key or
even a part of the primary key, and total_marks depends on it.This is Transitive Dependency.
When a non-prime attribute depends on other non-prime attributes rather than depending upon
the prime attributes or primary key.
How to remove Transitive Dependency
Again the solution is very simple. Take out the columns exam_name and total_marks from
Score table and put them in an Exam table and use the exam_id wherever required.
Advantage of removing Transitive Dependency