Skip to content
SPM Tuition
Computer Science · Relational data modelling

Explaining update anomalies before normalising

You are told to normalise a table, but you cannot explain what goes wrong if you do not.

A flat table that repeats facts causes three problems: update, insertion and deletion anomalies. Normalising fixes them by storing each fact once.

This lesson belongs to relational data modelling. It gives the reasons behind normalising a small data set.

What does the flat table look like?

An original bookshop records orders in one table.

OrderID Customer Phone Book Qty
101 Aina 012-111 Atlas 1
102 Aina 012-111 Dictionary 2
103 Bala 013-222 Atlas 1

Aina’s phone number is stored in two rows.

Worked example: the three anomalies

Update anomaly. Aina changes her phone number to 012-999. The shop edits row 101 but forgets row 102. Now the table holds two different numbers for Aina, and nobody knows which is right.

Insertion anomaly. A new customer, Chen, registers but has not ordered anything. There is no OrderID to put in the row, so the shop cannot record Chen’s details without inventing an order.

Deletion anomaly. Bala cancels order 103 and the row is deleted. Bala’s name and phone number disappear with it, although he is still a customer.

How does splitting the data fix this?

Separate the facts into two tables, linked by CustomerID.

Customer

CustomerID Name Phone
C1 Aina 012-111
C2 Bala 013-222

Order

OrderID CustomerID Book Qty
101 C1 Atlas 1
102 C1 Dictionary 2
103 C2 Atlas 1

Aina’s phone now lives in one row, so one edit updates it everywhere. Chen can be added to Customer without an order. Deleting order 103 leaves Bala in Customer.

The mistake that costs marks

Students write “normalising makes the database smaller” or “neater”. Those answers do not explain a problem.

Weak answer Strong answer
“It makes the table neater.” “Aina’s phone number is stored in two rows, so updating one row leaves the data inconsistent. After splitting, it is stored once.”

The fix is to name the repeated fact, show what goes wrong, and say where the fact lives after the split.

Check yourself

A table lists Student, Class and Class Teacher in each row. The teacher’s name repeats for every student in the class. Describe one update anomaly and one deletion anomaly.

Answer

Update anomaly: the class teacher changes, but only some student rows are edited, so the table shows two teachers for one class.

Deletion anomaly: the last student in a class leaves and the row is deleted, so the class teacher’s name is lost too.

What to study next

Put these ideas to work by splitting a table yourself. Continue with normalising a small data set within syllabus scope, then check your links using checking a foreign key against sample rows.

If you want a teacher to practise these explanations with you, see online one-to-one Computer Science tuition.

Common questions

What is an update anomaly?

An update anomaly happens when one fact is stored in several rows and only some of them are changed. The data then contradicts itself. For example, a customer's phone number appears in three order rows, and only two are updated.

What are insertion and deletion anomalies?

An insertion anomaly means you cannot record one fact without another, such as adding a customer who has not ordered yet. A deletion anomaly means removing one row also removes a separate fact, such as deleting the last order and losing the customer's details.

How does normalising fix these?

Normalising splits the data so each fact is stored once, in its own table, linked by keys. A phone number then sits in one Customer row, so one change is enough. The anomalies disappear because the repeated data is gone.

If you can normalise a table but cannot say why, a one-to-one Computer Science teacher can practise the explanation with you until you can give it in two sentences.

  • Online one-to-one lessons for your child with an experienced teacher.
  • Your first class is a one-hour trial, from RM50. The fee is agreed before you book.
  • Happy with the teacher? Continue with lessons of about 1.5 hours. If not, ask for another teacher.