Introduction
A functional dependency (FD) says that the values of attributes determine the values of attributes : two tuples that agree on must agree on . FDs are how the real-world rules of an application ("a roll number determines the student's name", "a course and a semester determine the instructor") are written down for a relation.
FDs drive the rest of database design. Keys are defined through them, the later FD-based tests for 2NF, 3NF and BCNF are conditions on them, and lossless decomposition is tested with them. The three computations that the later notes rely on are taught here: attribute closure, implication of an FD, and the canonical (minimal) cover.
Prerequisites
- Relational Model and Keys: superkey and candidate key, which are re-expressed through closure.
Core concepts
Definition. For attribute sets , relation instance satisfies if for all tuples , implies . The FD holds on schema if every legal instance satisfies it. As with keys, an instance can refute an FD but never prove it.
| Term | Meaning |
|---|---|
| Trivial FD | with ; satisfied by every instance |
| (closure of ) | all FDs logically implied by the set |
| (attribute closure) | all attributes with in |
| Superkey | with |
| Equivalent sets | and with |
| Extraneous attribute | an attribute that can be removed from a left or right side without changing |
Armstrong's axioms
For attribute sets :
- Reflexivity. If then .
- Augmentation. If then .
- Transitivity. If and then .
They are sound (they derive only FDs that hold) and complete (they derive every FD in ). Derived rules:
- Union. and give .
- Decomposition. gives and .
- Pseudotransitivity. and give .
Not a rule. does not give , and with does not give anything about and together beyond .
How it works: attribute closure
Algorithms and pseudocode
CLOSURE(X, F)
result <- X
repeat
changed <- false
for each FD (L -> R) in F
if L is a subset of result and R is not a subset of result then
result <- result union R; changed <- true
until not changed
return resultEach pass costs set operations, and there are at most productive passes, so the simple algorithm is ; a counter-based version runs in time linear in the total size of .
Uses: is in iff ; is a superkey iff ; and are equivalent iff every FD of follows from and every FD of follows from .
CANONICAL-COVER(F)
replace each FD X -> A1...Ak by X -> A1, ..., X -> Ak // single attribute right sides
for each FD X -> A and each attribute B in X // left-reduce
if A is in CLOSURE(X - {B}, F) then replace X by X - {B}
for each FD f in F // remove redundant FDs
if f follows from F - {f} then delete f
return F (optionally merge FDs with equal left sides by union)The left-reduction test uses the original : is extraneous in when computed under . Left-reduce before removing redundant FDs; doing it the other way round can leave a redundant FD behind.
Mathematical explanation
Why closure is correct. Every attribute added is justified by transitivity and union from FDs already derived, so the algorithm is sound. For completeness, build a two-tuple instance that agrees exactly on and differs elsewhere: it satisfies every FD of (any FD whose left side is inside has its right side inside , by the stopping condition), yet violates for every . So no attribute outside is implied.
Counting trivial FDs. On attributes, choosing means deciding for each attribute whether it is in , in only, or in neither: trivial FDs (empty sets allowed). The total number of FDs is .
A canonical cover is not unique. has the two canonical covers and ; both are minimal and both are equivalent to .
Worked examples
Example 1: closure and keys. With of Figure 1 on :
- , so is a superkey; neither nor is , so is a candidate key.
- , so does not hold.
- appears on no right side, so is in every key. Trying with each other attribute: , , , , all have closure . The candidate keys are exactly these five.
Example 2: canonical cover. .
- Split: .
- Left-reduce : contains , so is extraneous: . Left-reduce : contains , so is extraneous: , a duplicate.
- Remove redundant FDs: follows from and .
Canonical cover: , or merged, .
Example 3: equivalence. and are equivalent: under , covers and ; under , covers and . is not equivalent to : does not follow from , because under .
Example 4: does an instance satisfy an FD? Instance of : , , , . Holds: (the two tuples with both have ), ? No: appears with 2 and 3. ? No: appears with and . : yes. : no.
Example 5: minimal covers can differ in size. Take the of the non-uniqueness remark in the Mathematical explanation: every pair of , , determines each other in both directions, so . A minimal cover here is any set of single-attribute FDs, with no redundant FD, under which all three attributes reach each other. Checking every candidate set gives exactly five:
- two cycles with 3 FDs: and ;
- three stars with 4 FDs, one centred on each attribute, for example centred on .
In a star no FD is redundant: dropping leaves nothing that reaches . So "the number of FDs in a minimal cover" is not determined by ; a question that asks for it has to fix the procedure or the starting order.
Example 6: counting the FDs in . , . For a left side , the FDs in are exactly those with , so there are of them (the empty included).
| 1 | 8 | 4 | 2 | 8 | 8 | 4 | 8 |
- Total with empty sets allowed: ; with a nonempty left side: .
- Trivial FDs (): . Nontrivial (): .
State which convention you use: whether the empty set may appear on either side, and whether trivial FDs are counted.
Important properties and observations
- Right sides split, left sides do not. is equivalent to the pair , ; does not in general imply or . A left-side attribute may be removed only when the extraneous-attribute closure test succeeds.
- Every FD with a superkey on the left holds. Superkeys are exactly the left sides whose closure is ; candidate keys are inclusion-minimal such sets.
- Order of canonical-cover steps matters: left-reduce first, then remove redundant FDs.
- Extraneous on the right: after splitting into single attributes, an extraneous right-side attribute shows up as a redundant FD.
- FD versus relation property. An FD on says is the graph of a function from -values to -values (see Relations).
Common misconceptions.
- " implies ." It does not.
- "The canonical cover is unique." Several are possible; all are equivalent.
- "An instance that satisfies proves the FD." It only fails to refute it.
GATE examination perspective
- Closure computations. Compute , decide whether an FD is implied, decide whether a set is a key.
- Candidate keys from FDs. Core attributes (on no right side) plus minimal extensions.
- Canonical cover. Count the FDs in a minimal cover, or pick which set is a minimal cover of .
- Equivalence of FD sets. Check each direction with closures.
- Instance questions. Which FDs a given table satisfies.
Summary
Sources
- A. Silberschatz, H. F. Korth, S. Sudarshan, Database System Concepts, 7th ed., McGraw-Hill, 2019 (2020 copyright), 7.2 Decomposition Using Functional Dependencies, 7.4 Functional-Dependency Theory.
- R. Elmasri, S. B. Navathe, Fundamentals of Database Systems, 7th ed., Pearson, 14.2 Functional Dependencies; 15.1 Further Topics in Functional Dependencies: Inference Rules, Equivalence, and Minimal Cover.
