2.6 Anomalies in DBMS
2.6 Anomalies in DBMS
Table: Employee
1. Update anomaly: In the above table we have two rows for employee Rick as he
belongs to two departments of the company. If we want to update the address of Rick
then we have to update the same in two rows or the data will become inconsistent.
If somehow, the correct address gets updated in one department but not in other then as
per the database, Rick would be having two different addresses, which is not correct and
would lead to inconsistent data.
2. Insert anomaly: An insertion anomaly occurs when you are inserting inconsistent
information into a table.
Suppose a new employee joins the company, who is under training and currently not
assigned to any department then we would not be able to insert the data into the table if
emp_dept field doesn’t allow nulls.
3. Delete anomaly: A deletion anomaly occurs when you delete a record that may
contain attributes that shouldn’t be deleted.
Suppose, if at a point of time the company closes the department D890 then deleting the
rows that are having emp_dept as D890 would also delete the information of employee
Maggie since she is assigned only to this department.
customer 1313131 is displayed twice, once for account no. A-101 and again for
account A-102. In this case, the customer number is not redundant, although there are
deletion anomalies with the table. Having a separate customer table would solve this
problem. However, if a branch address were to change, it would have to be updated in
multiple places.
Insertion Anomaly
When we insert a new record, such as account no. A-306 in Figure 10.2, we need
to check that the branch data is consistent with existing rows.
Update Anomaly
If a branch changes address, such as the Round Hill branch, we need to update all rows
referring to that branch. Changing existing information incorrectly is called an update
anomaly.
Deletion Anomaly
A deletion anomaly occurs when you delete a record that may contain attributes that
shouldn’t be deleted. For instance, if we remove information about the last account at a
branch, such as account A-101 at the Downtown branch in Figure 10.4, all of the branch
information disappears.
1. Insertion anomaly: If a tuple is inserted in referencing relation and referencing
attribute value is not present in referenced attribute, it will not allow inserting in
referencing relation. For Example, If we try to insert a record in STUDENT_COURSE
with STUD_NO =7, it will not allow.
2. Deletion and Updation anomaly: If a tuple is deleted or updated from referenced
relation and referenced attribute value is used by referencing attribute in referencing
relation, it will not allow deleting the tuple from referenced relation. For Example, If we
try to delete a record from STUDENT with STUD_NO =1, it will not allow. To avoid
this, following can be used in query: