DBMS Notes
The closure of a set of attributes X (denoted X⁺) under a set of functional dependencies F is the set of ALL attributes that can be functionally determined...
Definition
The closure of a set of attributes X (denoted X⁺) under a set of functional dependencies F is the set of ALL attributes that can be functionally determined by X. In other words, X⁺ contains every attribute A such that X → A can be derived from F using Armstrong's Axioms.
Attribute closure is one of the most fundamental tools in database theory. It serves as the workhorse for checking superkeys, finding candidate keys, verifying whether a functional dependency holds, and computing canonical covers.
Applications of Attribute Closure
1. Check if X is a Superkey
X is a superkey of relation R if X⁺ contains ALL attributes of R.
| Start | {A} |
| A->B | {A, B} |
| B->C | {A, B, C} |
| C->D | {A, B, C, D} = all attributes of R |
2. Check if X is a Candidate Key
A candidate key is a minimal superkey. After confirming X is a superkey, check that no proper subset of X is also a superkey.
3. Verify if an FD Holds
The FD X → Y holds under F if and only if Y ⊆ X⁺.
| Start | {A, C} |
| A->B | {A, B, C} |
| BC->D | B and C are both in result -> {A, B, C, D} |
4. Finding Canonical Cover
Used to simplify a set of FDs by removing redundant dependencies and redundant attributes from left-hand sides.
Detailed Worked Examples
Example 1 — Basic Closure Computation
| Step 0 | result = {A, E} |
| A -> BC | A in result -> add B, C -> result = {A, B, C, E} |
| CD -> E | C in result but D not -> skip |
| B -> D | B in result -> add D -> result = {A, B, C, D, E} |
| E -> A | E in result, A already present -> no change |
| A -> BC | already have B, C |
| CD -> E | C,D in result, E already present |
| B -> D | already have D |
| E -> A | already have A |
| A⁺ | {A} -> A->BC -> {A,B,C} -> B->D -> {A,B,C,D} -> CD->E -> {A,B,C,D,E} |
| E⁺ | {E} -> E->A -> {A,E} -> A->BC -> {A,B,C,E} -> B->D -> {A,B,C,D,E} |
| Candidate keys | A and E (both are minimal superkeys). |
Example 2 — Finding All Candidate Keys
| Strategy | Start with attributes that NEVER appear on the RHS of any FD. |
| RHS attributes | R, S, P |
| Compute Q⁺ | {Q} -> no FD has just Q on LHS -> Q⁺ = {Q} |
| Candidate Keys | PQ, QR, QS |
Example 3 — Checking if a Decomposition is Lossless
| Decomposed into | R1(A, B, C) and R2(A, D) |
| Common attributes | A |
| (The condition | common attributes must be a superkey of at least one Ri) |
Systematic Method for Finding All Candidate Keys
| Step 1 | Identify attributes that appear ONLY on LHS (never on RHS) |
| Step 2 | Identify attributes that appear ONLY on RHS (never on LHS) |
| Step 3 | Start with the "must-have" attributes. |
| Example | R(A, B, C, D, E, F) |
| LHS attributes | A, B, C, D, E, F |
| RHS attributes | C, D, E, F, A |
| (AB)⁺ | {A,B} -> AB->C -> {A,B,C} -> C->D -> {A,B,C,D} |
| (BC)⁺ | {B,C} -> C->D -> {B,C,D} -> D->E -> {B,C,D,E} |
| Similarly | BD, BE, BF are all CKs (each eventually reaches all attributes). |
| Candidate Keys | AB, BC, BD, BE, BF |
Common Mistakes
- Stopping too early: Always iterate until no new attributes are added. One pass through the FDs may not be enough.
- Forgetting transitivity: If A->B and B->C are in F, then A⁺ must include C.
- Confusing closure of attributes with closure of FDs: X⁺ is a set of attributes; F⁺ is a set of all FDs implied by F.
Mastering attribute closure computation is essential — it appears in nearly every normalization problem on exams and is the foundation for all higher normal form testing.
Continue the lesson path