Anomalies in DBMS
Anomalies in DBMS
Typically arise in poorly designed or unnormalized tables, leading to various problems related to
data consistency, redundancy, and integrity. Below are situations where insertion, deletion, and
update anomalies occur, along with solutions for each using examples.
1. Insertion Anomaly
Situation:
An insertion anomaly occurs when certain data cannot be inserted into the database without the
presence of other unnecessary data. This usually happens in tables where multiple pieces of
unrelated data are stored together.
Example:
Consider the table Employee_Project, which stores both employee and project details:
If you want to insert a new project P003 (AI Development) that no employee is currently
working on, you cannot insert this project because the table requires employee information. The
table structure forces the presence of employee data, which is irrelevant in this case.
Solution:
To eliminate this insertion anomaly, normalize the table by separating project details and
employee details into two tables:
1. Project Table:
FCSDI 1
2. Employee_Project Table:
This way, the project can be added to the Project table without needing any employee
information.
2. Deletion Anomaly
Situation:
A deletion anomaly occurs when the deletion of a piece of data leads to the unintentional loss of
other important data.
Example:
Consider the following table Employee_Department, which stores both employee and
department information:
Now, if both Sarah and Bob leave the company and we delete their records, we also lose all
information about the HR department, including its manager (Manager A). This happens because
the department and employee data are stored together, leading to the unintentional loss of
department data.
Solution:
To prevent deletion anomalies, normalize the data by separating employee and department
information into two tables:
1. Department Table:
2. Employee_Department Table:
FCSDI 2
Employee_ID Employee_Name Dept_ID
201 Sarah D001
202 Bob D001
203 Mike D002
3. Update Anomaly
Situation:
An update anomaly occurs when multiple instances of the same data are stored redundantly,
requiring updates in multiple places. If one place is not updated, inconsistencies occur.
Example:
Consider the Employee_Project table again, where employee information and project details
are stored together:
If the project location for P101 changes from "New York" to "Boston", we need to update this in
all rows where P101 appears. If we miss updating one row, we will have inconsistent data.
Solution:
To avoid update anomalies, separate the project information into its own table:
1. Project Table:
FCSDI 3
Project_ID Project_Name Project_Location
P101 Web App Boston
P102 Mobile App Chicago
2. Employee_Project Table:
Now, if the project location changes, it needs to be updated only once in the Project table,
avoiding inconsistencies.
Insertion Anomaly:
Situation: Unable to insert new data unless other unrelated data is present.
Solution: Normalize the database to separate unrelated data into different tables.
Deletion Anomaly:
Situation: Deleting one piece of data unintentionally deletes other important data.
Solution: Split data into different tables based on their logical relationships.
Update Anomaly:
By using normalization techniques, especially up to 3rd normal form (3NF), we can avoid
these anomalies and maintain a well-structured, consistent, and efficient database.
FCSDI 4