DBMS Anomalies (Insertion, Update, Deletion)

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.

What are Anomalies in DBMS?

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.

Example Table

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.

Types of Anomalies

Insertion Anomaly in DBMS

Insertion anomaly occurs when we are unable to add new data into the database without entering unnecessary or unavailable information.

πŸ“Š Real-World Example

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

βž• Situation

The college wants to introduce a new course "Machine Learning" (Code: ML-2) with a fee of β‚Ή8000.

⚠️ What’s the Problem?

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.

🚨 The Risk

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."

βœ… Final Understanding

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 in DBMS

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.

πŸ“Š Real-Life Scenario

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

⚠️ Scenario Change

The college decides to increase the DBMS course fee from β‚Ή7000 β†’ β‚Ή8000.

❗ The Problem

The course "DBMS" appears in multiple rows. You must update the fee for Ayush,Anuj, and Vijay separately.

🚨 The Risk

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?"

βœ… Conclusion

This inconsistency is called Update Anomaly. It happens due to data redundancy and poor table design.

Deletion Anomaly in DBMS

Deletion anomaly occurs when removing a record also deletes other important information unintentionally from the database.

πŸ“Š Real-World Example

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

πŸ—‘οΈ Situation

Riya is the only student enrolled in the course MACHINE LEARNING (ML-2). He decides to drop the course.

⚠️ What’s the Problem?

When we delete Riya’s record, we also remove the only row that contains information about the ML course.

🚨 The Risk

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."

βœ… Final Understanding

This is called Deletion Anomaly. It happens when deleting one piece of data unintentionally removes other valuable information.

Final Summary

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.

Frequently Asked Questions

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.

How to Remove Anomalies in DBMS?

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.

πŸ› οΈ The Solution: Normalization

Normalization is a process of structuring a database into smaller, well-organized tables. It ensures that each piece of information is stored only once.

πŸ“‚ Decomposition (Breaking the Table)

In decomposition, we divide a large table into multiple smaller tables based on their relationships. Each table focuses on a specific type of data.

πŸ“Š Example (Before vs After)

Before (Single Table):

After (Decomposed Tables):

βœ… Why This Works

"Data ko alag-alag jagah organize karo, taaki ek change se poora system disturb na ho."

🎯 Final Understanding

By using normalization and decomposition, we design a database that is clean, efficient, and free from anomalies.

Decomposition

πŸ”— Related Topics