0% found this document useful (0 votes)
154 views4 pages

2.6 Anomalies in DBMS

The document discusses different types of anomalies that can occur when a database is not properly normalized. It provides examples of insertion, update, and deletion anomalies using tables that store employee data and customer account data. Insertion anomalies occur when inconsistent data cannot be inserted. Update anomalies happen when changing an attribute requires updating it in multiple places. Deletion anomalies result when deleting a record also deletes attributes that should remain. Proper normalization of tables can prevent these anomalies.

Uploaded by

2002746.it.cec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
154 views4 pages

2.6 Anomalies in DBMS

The document discusses different types of anomalies that can occur when a database is not properly normalized. It provides examples of insertion, update, and deletion anomalies using tables that store employee data and customer account data. Insertion anomalies occur when inconsistent data cannot be inserted. Update anomalies happen when changing an attribute requires updating it in multiple places. Deletion anomalies result when deleting a record also deletes attributes that should remain. Proper normalization of tables can prevent these anomalies.

Uploaded by

2002746.it.cec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Anomalies in DBMS

 In database design, redundancy is generally undesirable because it causes


problems maintaining consistency after updates. However, redundancy can
sometimes lead to performance improvements; for example, when redundancy
can be used in place of a join to connect data. A join is used when you need to
obtain information based on two related tables.
 There are three types of anomalies that occur when the database is not normalized.
These are – Insertion, update and deletion anomaly.

Suppose a manufacturing company stores the employee details in a table named


employee that has four attributes: emp_id, emp_name, emp_address and emp_dept.

Table: Employee

emp_id emp_name emp_address emp_dept


101 Rick Delhi D001
101 Rick Delhi D002
123 Maggie Agra D890
166 Glenn Chennai D900
166 Glenn Chennai D004
The above table is not normalized.

Following problems may arise when a relation or table is not normalized.

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.

To overcome these anomalies we need to normalize the data.

Example 2: Anomalies in DBMS

 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:

 ON DELETE/UPDATE SET NULL: If a tuple is deleted or updated from


referenced relation and referenced attribute value is used by referencing attribute in
referencing relation, it will delete/update the tuple from referenced relation and set
the value of referencing attribute to NULL.
 ON DELETE/UPDATE CASCADE: If a tuple is deleted or updated from
referenced relation and referenced attribute value is used by referencing attribute in
referencing relation, it will delete/update the tuple from referenced relation and
referencing relation as well.

You might also like