Chapter 02
Functional Dependencies & Normalization
5 topics · 1 sections · beginner-friendly study notes · Updated
Normalization is the step-by-step process of splitting a badly designed table into smaller good tables, so data is not repeated and updates do not cause errors.
Functional dependencies (FDs) are the rules that guide this process.
Finding candidate keys, checking the highest normal form and testing lossless decomposition are asked in GATE almost every year.
Cleaning up a messy student, order or salary table so that each fact is stored only once.
Functional Dependencies
A functional dependency X → Y means that if two rows have the same value of X, they must have the same value of Y. X is the determinant and Y is the dependent.
In short: If you know the roll number, you can find exactly one name. So roll_no → name.
Think about it
FDs describe the real business rules of the data. Normalization uses them to decide how to split tables. In a bank, account_no → balance, branch_name. Knowing the account number tells you exactly one balance and one branch.
Think of a college table.
roll_no → name, because one roll number has one name.
But name → roll_no is false, because two students can share a name.
A dependency is trivial when Y is a subset of X (for example AB → A).
The closure of a set X, written X+, is the set of all attributes that can be found from X using the FDs.
To compute X+, start with X, then keep adding the right side of every FD whose left side is already inside the set, until nothing new appears.
If X+ contains all attributes, X is a super key.
Armstrong axioms: reflexivity (if Y ⊆ X then X → Y), augmentation (X → Y gives XZ → YZ), transitivity (X → Y and Y → Z gives X → Z).
Derived rules: union, decomposition and pseudo-transitivity.
Key points
- Determinant: The left side X of X
→Y. - Trivial FD: X
→Y where Y is a subset of X. - Closure X+: All attributes that X can determine.
- Canonical (minimal) cover: Smallest equivalent set of FDs: single attribute on right, no extra left attributes, no redundant FD.
- Armstrong axioms are sound and complete.
- X is a super key exactly when X+ contains all attributes of the relation.
- Anomalies caused by bad design: insertion, deletion and update anomalies.
Read more
Candidate Keys Algorithm
Candidate keys can be found by checking attribute closures. Attributes that never appear on the right side of any FD must be in every key. Attributes that appear only on the right side are in no key.
In short: Start with the attributes that nobody else can give you. If they are enough, you have the key. If not, add more attributes one by one.
Think about it
You need the keys first to decide which attributes are prime. Only then can you say whether a table is in 2NF, 3NF or BCNF.
Step 1: List all attributes.
Step 2: Find attributes that never appear on any right side.
These must be part of every candidate key.
Call the set Core.
Step 3: Compute Core+.
If it contains all attributes, Core is the only candidate key.
Step 4: If not, add one more attribute at a time (then two at a time) and check closures.
Every minimal set whose closure is everything is a candidate key.
Step 5: Attributes that appear only on the left side or on both sides are the ones to try.
Attributes that appear only on the right side never go into a key.
Always check minimality: no smaller subset should also be a key.
Key points
- Core attributes: Attributes not on the right side of any FD; they are in every key.
- Prime attribute: Part of some candidate key.
- Non-prime attribute: Not part of any candidate key.
- A relation can have more than one candidate key.
- If every attribute appears on the right side of some FD in a cycle (like A
→B, B→A), several keys are possible.
Read more
1NF & 2NF Rules
First Normal Form (1NF): every cell holds a single atomic value, with no repeating groups or lists. Second Normal Form (2NF): the table is in 1NF and has no partial dependency, which means no non-prime attribute depends on only a part of a candidate key.
In short: 1NF: one value per cell. 2NF: every detail must depend on the whole key, not just a piece of it.
Think about it
These two rules remove the most common repetition and the update, insertion and deletion anomalies. A college stores student name again and again in each course row. If the name is spelled wrong in one row only, the data becomes inconsistent.
1NF example: a student row with phone = "9810, 9820" breaks 1NF.
Give each phone its own row.
2NF applies only when the key is composite.
Take Enrolment(student_id, course_id, student_name, grade) with key (student_id, course_id).
The FD student_id → student_name is a partial dependency, because name depends on only a part of the key.
This causes repetition: the student name is stored in every course row.
Fix: move student_name into a Student table.
Tables with a single-attribute key are always in 2NF if they are in 1NF.
Key points
- Atomic value: A value that cannot be split further for the application.
- Partial dependency: A non-prime attribute depends on part of a composite candidate key.
- Update anomaly: Changing a fact in one row but not in others.
- 2NF problem = partial dependency. It needs a composite key.
- A table whose candidate keys are all single attributes is automatically in 2NF.
Example
CodeRemoving a partial dependency: -- Before: partial dependency student_id -> student_name -- enrolment(student_id, course_id, student_name, grade) -- After 2NF CREATE TABLE student (student_id INT PRIMARY KEY, student_name VARCHAR(60)); CREATE TABLE enrolment (student_id INT, course_id INT, grade CHAR(2), PRIMARY KEY (student_id, course_id));
Advantages of normalization
Less repetition, fewer anomalies, smaller tables, easier updates and better data accuracy.
Disadvantages of normalization
More tables, more joins at query time, and slower reads.
Reporting systems sometimes denormalize on purpose.
3NF vs BCNF
Third Normal Form (3NF): for every FD X → A, either X is a super key or A is a prime attribute. Boyce-Codd Normal Form (BCNF): for every non-trivial FD X → Y, X must be a super key.
In short: BCNF is the strict rule: only keys can decide other things. 3NF is a little more relaxed: it also allows a prime attribute on the right side.
Think about it
These are the normal forms used in practice. They remove transitive dependencies and the remaining anomalies. Storing student, department and department head in one table repeats the head name for every student. Splitting the table fixes it.
A transitive dependency happens when a non-prime attribute depends on another non-prime attribute, such as student_id → dept_id and dept_id → dept_name.
This breaks 3NF.
Fix: split into Student(student_id, dept_id) and Department(dept_id, dept_name).
Every BCNF table is also in 3NF, but not the other way.
A table can be in 3NF but not BCNF only when a prime attribute depends on a non-key.
Example
R(A, B, C) with FDs AB → C and C → B. Keys are AB and AC.
C → B has B prime, so 3NF holds.
But C is not a super key, so BCNF fails.
Important facts: a lossless and dependency-preserving 3NF decomposition always exists.
BCNF is always lossless, but may not preserve dependencies.
Key points
- Transitive dependency: Non-prime
→non-prime through an intermediate attribute (A→B, B→C). - BCNF: Every determinant of a non-trivial FD is a super key.
- Order of strength: BCNF ⊂ 3NF ⊂ 2NF ⊂ 1NF.
- Shortcut: if all attributes are prime, the table is in 3NF.
- If the table has only two attributes, it is always in BCNF.
- 3NF can always be both lossless and dependency preserving. BCNF is always lossless but not always dependency preserving.
Read more
Lossless Decomposition
A decomposition of R into R1 and R2 is lossless if joining R1 and R2 gives back exactly the original R, with no missing and no extra (spurious) rows.
In short: After cutting a table into pieces, you should be able to glue the pieces together and get the exact original table.
Think about it
Normalization is only safe if we never lose information while splitting tables. If a bank splits Customer and Loan data on a non-key column such as city, joining them back may connect the wrong customers and loans.
Binary test: R is split into R1 and R2.
The split is lossless if (R1 ∩ R2) → R1 or (R1 ∩ R2) → R2 holds, which means the common attributes form a key of at least one part.
Example
R(A, B, C) with A → B split into R1(A, B) and R2(A, C).
The common attribute is A, and A → B, so A is a key of R1.
The split is lossless.
If we split into R1(A, B) and R2(B, C) instead, the common attribute B does not determine A or C. So extra rows can appear after the join.
Dependency preservation is a separate property: every original FD can be checked inside a single smaller table without joining.
Always aim for lossless; dependency preservation is nice to have.
Key points
- Spurious tuple: A wrong extra row created by joining badly decomposed tables.
- Dependency preservation: All original FDs can be enforced on the smaller tables.
- Lossless test for two tables: common attributes must be a super key of R1 or R2.
- Lossless and dependency preserving are independent properties.
Read more
Solved examples
R(A, B, C, D, E) with FDs A → B, B → C, CD → E. Find A+.
Closure of A
Formula Applied:—Approach note: Keep applying FDs until no new attribute can be added.
R(A, B, C, D) with FDs AB → C, C → D, D → A. Find all candidate keys and the highest normal form.
Candidate keys and normal form
Formula Applied:—Approach note: If all attributes are prime, 3NF is automatic. Then test each FD for BCNF.
Enrolment(student_id, course_id, student_name, grade) has FDs student_id → student_name and (student_id, course_id) → grade. What is the highest normal form?
Highest normal form and fix
Formula Applied:—Approach note: Partial dependency means 2NF is broken.
R(A, B, C) with A → B is decomposed into R1(A, B) and R2(A, C). Is it lossless?
Lossless or not
Formula Applied:—Approach note: Common attributes must be a super key of R1 or R2.
Real-world applications
Using Functional Dependencies & Normalization in real projects
Cleaning up a messy student, order or salary table so that each fact is stored only once.
Common mistakes
❌ Myth: Every table in 3NF is also in BCNF.
Why this is wrong: BCNF is stricter. 3NF allows prime attributes on the right side of a dependency.
✅ Verified Truth: BCNF ⊂ 3NF. A table can be in 3NF and still violate BCNF.
⚠️ Exam Tip: Look for an FD whose left side is not a super key but the right side is prime.
❌ Myth: BCNF decomposition always preserves dependencies.
Why this is wrong: Some FDs can be spread over two tables after a BCNF split.
✅ Verified Truth: BCNF is always lossless but may lose dependency preservation. 3NF can have both.
⚠️ Exam Tip: Quote this when asked why 3NF is used in practice.
❌ Myth: A lossless decomposition is also dependency preserving.
Why this is wrong: The two properties are independent.
✅ Verified Truth: A split can be lossless but still lose an FD, or preserve FDs but be lossy.
⚠️ Exam Tip: Test each property separately.
Revision notes
Normalization is the step-by-step process of splitting a badly designed table into smaller good tables, so data is not repeated and updates do not cause errors. Functional dependencies (FDs) are the rules that guide this process.
High-Yield Quick Revision Points
- X → Y: same X means same Y
- X+ closure; X is a super key when X+ has all attributes
- Attributes never on the right side are in every key
- 1NF: atomic cells. 2NF: no partial dependency
- 3NF: X is a super key OR A is prime. BCNF: X is a super key
- All attributes prime → at least 3NF
- Lossless: R1 ∩ R2 is a key of R1 or R2
- BCNF always lossless, not always dependency preserving
Practice questions
R(A, B, C) with FDs A → B and B → C. What is A+?
A partial dependency violates which normal form?
A relation where all attributes are prime is always in at least:
Which statement is TRUE?
R is split into R1 and R2. The join is lossless when R1 ∩ R2 is: