Learn DBMS anomalies (Insertion, Update, Deletion) in a simple and practical way. This guide explains real-world problems in database design and how they lead to data inconsistency, redundancy, and data loss. You will also learn how to solve these issues using normalization and decomposition.
Anomalies in DBMS are problems that occur when a database is not properly structured. These problems lead to data inconsistency, redundancy, and loss of information.
Anomalies mainly occur in unnormalized tables where data is stored inefficiently.
| StudentID | StudentName | City | CourseCode | CourseName | CourseFee |
|---|---|---|---|---|---|
| 501 | Ayush | Mumbai | DB-1 | DBMS | βΉ7000 |
| 502 | Anuj | Bihar | DB-1 | DBMS | βΉ7000 |
| 503 | Vijay | Kota | DB-1 | DBMS | βΉ7000 |
| 504 | Riya | Bihar | ML-2 | Machine Learning | βΉ5000 |
| 505 | Aarti | Patna | CD-1 | Coding | βΉ10000 |
This table will help us understand different anomalies.
Insertion anomaly occurs when we are unable to add new data into the database without entering unnecessary or unavailable information.
| StudentID | StudentName | City | CourseCode | CourseName | CourseFee |
|---|---|---|---|---|---|
| 501 | Ayush | Mumbai | DB-1 | DBMS | βΉ7000 |
| 502 | Anuj | Bihar | DB-1 | DBMS | βΉ7000 |
| 503 | Vijay | Kota | DB-1 | DBMS | βΉ7000 |
The college wants to introduce a new course "Machine Learning" (Code: ML-2) with a fee of βΉ8000.
No student has enrolled in this course yet. Since the table requires a StudentID, we cannot insert this new course without adding fake or NULL student data.
If StudentID is a primary key, it cannot be NULL. This means the database will not allow inserting the new course at all.
"A new course has been launched, but the college cannot add it to the database because no student has enrolled yet."
This situation is called Insertion Anomaly. It occurs when the database structure forces us to enter unnecessary data just to insert valid information.
Update anomaly occurs when the same data is stored in multiple rows and we need to update it everywhere. If we miss even one place, the database becomes inconsistent.
| StudentID | StudentName | City | CourseCode | CourseName | CourseFee |
|---|---|---|---|---|---|
| 501 | Ayush | Mumbai | DB-1 | DBMS | βΉ7000 |
| 502 | Anuj | Bihar | DB-1 | DBMS | βΉ7000 |
| 503 | Vijay | Kota | DB-1 | DBMS | βΉ7000 |
| 504 | Riya | Bihar | ML-2 | Machine Learning | βΉ5000 |
| 505 | Aarti | Patna | CD-1 | Coding | βΉ10000 |
The college decides to increase the DBMS course fee from βΉ7000 β βΉ8000.
The course "DBMS" appears in multiple rows. You must update the fee for Ayush,Anuj, and Vijay separately.
If you update only two rows and forget one, the database will show different fees for the same course.
"How can the same course have different fees in one college?"
This inconsistency is called Update Anomaly. It happens due to data redundancy and poor table design.
Deletion anomaly occurs when removing a record also deletes other important information unintentionally from the database.
| StudentID | StudentName | City | CourseCode | CourseName | CourseFee |
|---|---|---|---|---|---|
| 501 | Ayush | Mumbai | DB-1 | DBMS | βΉ7000 |
| 502 | Anuj | Bihar | DB-1 | DBMS | βΉ7000 |
| 503 | Vijay | Kota | DB-1 | DBMS | βΉ7000 |
| 504 | Riya | Bihar | ML-2 | Machine Learning | βΉ5000 |
| 505 | Aarti | Patna | CD-1 | Coding | βΉ10000 |
Riya is the only student enrolled in the course MACHINE LEARNING (ML-2). He decides to drop the course.
When we delete Riyaβs record, we also remove the only row that contains information about the ML course.
As a result, details like course name, code, and fee are completely lost from the database.
"When the student leaves the course, the entire course information about the course is removed from the database."
This is called Deletion Anomaly. It happens when deleting one piece of data unintentionally removes other valuable information.
Anomalies occur due to poor database design and lead to data redundancy and inconsistency.
These problems can be solved by applying normalization and decomposition techniques.
What are anomalies in DBMS?
Anomalies are problems that occur due to poor database design, leading to inconsistency and redundancy.
Why do anomalies occur?
They occur because of repeated data and improper table structure.
How can anomalies be removed?
By using normalization and decomposition techniques.
Anomalies occur because data is stored in a single table with repetition. The solution is to organize the database in a way that avoids redundancy and keeps data consistent.
Normalization is a process of structuring a database into smaller, well-organized tables. It ensures that each piece of information is stored only once.
In decomposition, we divide a large table into multiple smaller tables based on their relationships. Each table focuses on a specific type of data.
Before (Single Table):
After (Decomposed Tables):
"Data ko alag-alag jagah organize karo, taaki ek change se poora system disturb na ho."
By using normalization and decomposition, we design a database that is clean, efficient, and free from anomalies.
Decomposition