Functional Dependencies
A functional dependency is a rule about the data: if you know X, you can determine Y. Normalization is the process of organizing tables so those rules do not create redundancy.
In plain English
If you know a student's ID, you know their name. That is a functional dependency.
The one idea
X → Y means every two tuples that agree on X must also agree on Y; the dependency is a rule, not a correlation you noticed once.
Functional dependencies are the evidence behind normalization. Without them, decomposition is just moving columns around.
By the end
- 01Read X → Y as a functional dependency.
- 02Apply Armstrong's axioms to derive dependencies.
- 03Compute an attribute closure.
- 04Identify partial and transitive dependencies.
The notation
X → Y means every pair of tuples that agree on X must also agree on Y. If student_id → student_name, two rows with the same student_id must have the same student_name. The dependency is a property of the domain, not of the current rows.
student_id -> student_name
course_id -> course_name
(student_id, course_id) -> gradeArmstrong's axioms
Reflexivity: if Y is a subset of X, then X → Y. Augmentation: if X → Y, then XZ → YZ. Transitivity: if X → Y and Y → Z, then X → Z. These three rules generate all dependencies implied by a set. Union and decomposition are derived rules.
reflexivity: if Y ⊆ X, then X -> Y
augmentation: if X -> Y, then XZ -> YZ
transitivity: if X -> Y and Y -> Z, then X -> ZClosure and candidate keys
The closure of X, written X+, is the set of all attributes determined by X. If X+ contains every attribute, X is a superkey. If no proper subset of X has that property, X is a candidate key. Computing closures is a systematic way to find keys from dependencies.
R(A, B, C, D)
A -> B
B -> C
A+ = {A, B, C}
A is not a key unless D is also determined.Partial and transitive dependencies
A partial dependency is a non-key attribute that depends on only part of a composite key. A transitive dependency is a non-key attribute that depends on another non-key attribute. Both are the targets of 2NF and 3NF respectively.
Advisor depends on student
A Student table contains student_id, student_name, advisor_id, and advisor_name.
Observe student_id → student_name and student_id → advisor_id.
The student id determines the student's own facts and their assigned advisor.
Observe advisor_id → advisor_name.
The advisor id determines the advisor name.
Compose the dependencies.
student_id → advisor_name is transitive, which is exactly the 3NF violation.
ConclusionA dependency found in one sample is not a guarantee. It becomes a schema rule only when the business confirms it or a constraint enforces it.
The trade-off
No free correctness.
Gain
A precise basis for keys, decomposition, and anomaly analysis.
Cost
Real domains have conditional dependencies and exceptions that are hard to enumerate.
Verdict
Write the dependencies down before normalizing; test them against future data, not just today's rows.
Recap
What to keep.
Takeaways
- +X → Y means X determines Y.
- +Armstrong's axioms derive all implied dependencies.
- +X+ is the set of attributes determined by X.
- +A candidate key determines every attribute and is minimal.
- +Partial and transitive dependencies cause redundancy.
Traps
- !Reading dependencies from a single sample table rather than the domain.
- !Forgetting that a candidate key must be minimal.
- !Confusing a superkey with a candidate key.
Focus
- →Compute a closure from a small dependency set.
- →Find a candidate key.
- →Identify a partial and a transitive dependency.
Check yourself
Before you turn the page.
What does X → Y mean?
Which axiom says if X → Y, then XZ → YZ?