Why Normalisation Exists: Anomalies and Redundancy
Redundancy causes three anomalies: you cannot insert a fact without an unrelated one, an update must change many rows, and a delete destroys information you meant to keep. Normalisation removes the cause.
-
DBMS Fundamentals
- Data, Information and Databases
- What a DBMS Is and Why It Exists
- File System versus DBMS
- Advantages and Limitations of a DBMS
- Database Users and the Role of the DBA
- Three Level Architecture and Data Abstraction
- Logical and Physical Data Independence
- Schema, Instance and Metadata
- Database Applications and the Database System Environment
- Database Architecture
- Data Models
-
ER Model
- Entities, Entity Sets and Entity Types
- Types of Attributes in the ER Model
- Keys in the ER Model
- Relationships, Relationship Sets and Degree
- Cardinality and Participation Constraints
- Strong and Weak Entities
- Drawing and Reading ER Diagrams
- Extended ER: Generalisation, Specialisation and Aggregation
- Converting an ER Diagram into Relational Tables
- ER Design Projects
- Relational Model
- Relational Algebra
- Functional Dependencies
-
Normalisation
- Why Normalisation Exists: Anomalies and Redundancy
- First Normal Form
- Second Normal Form and Partial Dependency
- Third Normal Form and Transitive Dependency
- BCNF and BCNF Decomposition
- 4NF, 5NF, Multivalued and Join Dependencies
- Lossless Decomposition and Dependency Preservation
- Complete Worked Normalisation: Unnormalised to BCNF
- Denormalisation and When to Use It
Concept
Normalisation is the process of organising attributes into relations so that redundancy is reduced and update anomalies are removed. It is not a style preference — each normal form removes one specific, demonstrable failure.
The badly designed relation
STUDENT_COURSE
roll | name | dept | dept_head | course | title | marks
-----+-------+------+-----------+--------+-----------+------
21 | Meera | CS | Dr Rao | CS201 | Databases | 87
21 | Meera | CS | Dr Rao | CS202 | Networks | 74
22 | Ravi | CS | Dr Rao | CS201 | Databases | 91
23 | Anitha| EC | Dr Iyer | EC101 | Circuits | 65
Look at what repeats:
Meera and CS and Dr Rao -> twice
Dr Rao -> three times
Databases -> twice
Every repetition is an opportunity for two copies to
disagree. That is the whole problem in one sentence.The three anomalies
1. Insertion anomaly
A fact cannot be recorded because an unrelated fact is missing.
The college creates a new department, Mathematics, headed
by Dr Nair. No students have joined yet.
Try to insert:
roll = ?, name = ?, dept = MA, dept_head = Dr Nair,
course = ?, title = ?, marks = ?
roll is part of the key, so it cannot be null.
You CANNOT record the department until a student exists.
Similarly, a new course with no enrolments cannot be
recorded either.2. Update anomaly
One change to one real world fact requires many rows to change, and any missed row makes the database contradict itself.
Dr Rao is replaced as head of Computing by Dr Menon.
Dr Rao appears in THREE rows. All three must change,
atomically. Update two and miss one:
21 | Meera | CS | Dr Menon | ...
21 | Meera | CS | Dr Menon | ...
22 | Ravi | CS | Dr Rao | ... <- contradiction
The database now asserts that Computing has two heads.
Nothing in it can tell which row is correct.3. Deletion anomaly
Removing one fact destroys another that you wanted to keep.
Anitha withdraws from EC101, so her row is deleted.
Deleted with it, and NOT deliberately:
that the EC department exists
that Dr Iyer heads it
that a course called Circuits exists
Those facts had no other row to live in. One student
leaving erased three unrelated pieces of information.Why the anomalies happen
Each one traces to a dependency whose determinant is not a key.
| Repeated fact | Dependency | Determinant is a key? |
|---|---|---|
| Student name | roll -> name | No — roll is only part of the key |
| Course title | course -> title | No — part of the key |
| Department head | dept -> dept_head | No — dept is not a key at all |
| Marks | {roll, course} -> marks | Yes — this one is fine |
The general principle behind every normal form: a fact should be stored once, in the relation whose key determines it. Everything from 1NF to BCNF is a particular way of enforcing that sentence.
The fix, previewed
DEPARTMENT ( dept, dept_head )
CS Dr Rao <- head stored ONCE
EC Dr Iyer
MA Dr Nair <- can exist with no students
STUDENT ( roll, name, dept )
21 Meera CS
22 Ravi CS
23 Anitha EC
COURSE ( course, title )
CS201 Databases <- can exist with no enrolments
CS202 Networks
EC101 Circuits
ENROLMENT ( roll, course, marks )
21 CS201 87
21 CS202 74
22 CS201 91
23 EC101 65
Now:
insert a department with no students -> fine
change the head -> ONE row
delete an enrolment -> loses nothing elseThe cost of normalisation
Normalisation is not free, and saying so is what separates understanding from recitation.
| Gain | Cost |
|---|---|
| No update anomalies | More relations to manage |
| Less storage for repeated values | More joins to answer the same question |
| Facts stored in one place | Some read queries become slower |
| Constraints easier to express | Design takes longer |
The usual engineering answer is to normalise to 3NF or BCNF for anything that is written to, and denormalise deliberately and locally where a read pattern proves it necessary. Note 6169 covers that decision.
The normal forms at a glance
| Form | Removes | Rule in one line |
|---|---|---|
| 1NF | Repeating groups | Every value is atomic |
| 2NF | Partial dependency | No non prime attribute depends on part of a key |
| 3NF | Transitive dependency | No non prime attribute depends on another non prime attribute |
| BCNF | Remaining key anomalies | Every determinant is a super key |
| 4NF | Multivalued dependency | No independent multivalued facts in one relation |
| 5NF | Join dependency | Cannot be split further without loss |
Common mistakes
- Describing normalisation as removing redundancy only. The point is the anomalies; redundancy is their cause.
- Believing it always improves performance. It improves write correctness and often costs read speed.
- Normalising without knowing the dependencies. Every normal form is defined in terms of them.
- Treating anomalies as rare. Any repeated value will eventually disagree with its copy.
Exam and interview questions
- Define insertion, update and deletion anomalies, with an example of each from one table.
- What causes anomalies, expressed in terms of dependencies and keys?
- State the one sentence principle behind all normal forms.
- Give two genuine costs of normalisation.
- Name each normal form and the single problem it removes.
Practice
- Design a badly normalised EMPLOYEE_PROJECT table and demonstrate all three anomalies on it.
- For the STUDENT_COURSE table above, list every fact stored more than once and count the copies.
- Explain in three sentences why the deletion anomaly is the most dangerous of the three.
Conclusion
Redundancy causes insertion, update and deletion anomalies, and redundancy arises when a fact is stored in a relation whose key does not determine it. Every normal form is a rule for putting each fact in the relation that owns it.