Attribute Closure with Respect to Functional Dependencies : Definition and Algorithm
In relational database theory, the attribute closure (also written as when emphasizing dependence on ) is the set of all attributes that are functionally determined by a starting set of attributes using a set of functional dependencies (FDs) . Formally, is the set of attributes such that (i.e., is logically implied by ).
A core motivation is that once you compute , you can answer common reasoning tasks:
- Does ? (Equivalent to )
- Find implied dependencies and support lossless reasoning for keys.
- Test candidate keys by checking whether some contains all attributes.
Key terms introduced here:
- Attribute closure
- Functional dependency (FD)
- Logical implication of FDs
- Key
- FD implication test
Attribute Closure (X+) and FD Inference
Definition (what means)
Given:
- attribute sets
- a set of FDs
the attribute closure is:
In other words, contains exactly those attributes that you can derive as consequences of applying FDs in , starting from the assumption that holds.
A practical corollary:
- iff .
This equivalence is the main “reasoning hook” for closure-based algorithms.
[CalloutBlock]
type: "tip"
title: "How to think about closure"
content: "Compute as “everything you can force to be equal (determined) if you know .” If is inside , then determines under ."
Why the closure algorithm works (intuition)
The standard closure computation repeatedly applies FDs whose left-hand sides are already “known” to be determined. Concretely:
- Start with containing the initially known attributes .
- If an FD in has , then you can conclude .
- Repeat until no more attributes can be added.
This is essentially computing a fixed point of repeated rule application, matching the semantics of logical implication for FDs (via Armstrong-style derivations).
Key terms:
- Fixed point
- Repeated application
- Termination
- Minimal augmentation step
- Monotonicity
Algorithm: Compute attribute closure $X^+$ with respect to FDs $F$
- 1Step 1
Set .
- 2Step 2
While there exists an FD in such that and , update .
- 3Step 3
When no FD can add new attributes, return the final .
“Commuting” for (order-independence / correctness idea)
In many courses, “commuting” here refers to the fact that the order in which FDs are applied does not affect the final closure: regardless of which eligible FD you apply first, you still reach the same fixed point .
You can view the algorithm as follows:
- At any time, the current working set (initially ) satisfies .
- Each time you apply an FD with , you enlarge to while preserving .
- Because only grows and there are finitely many attributes, the algorithm terminates.
- Once you reach a fixed point (no FD left with LHS contained), that fixed point must equal the least such fixed point—i.e., the true closure .
This yields the “commuting” property:
- Different application orders of eligible FDs commute to the same final closure.
[CalloutBlock]
type: "warning"
title: "Common mistake"
content: "Do not stop after a single pass over . Newly added attributes can enable additional FDs later, so you must iterate until no more attributes can be added."
Worked micro-example (closure computation)
Suppose:
Compute:
- Start:
- Apply :
- Apply :
- Apply :
No further FDs add attributes, so .
Thus and , and so on.
Closure Growth Illustration (conceptual)
Conceptual view: each satisfied FD adds attributes to the closure until a fixed point is reached.
Practice & Edge Cases
Closure Computation Lifecycle (fixed-point iteration)
Seed
1Set (initially known attributes)."
FD Activation
2If some FD has , activate it."
Augment
3Update (grow the determined attributes)."
Fixed Point
4Stop when no FD can add new attributes; return ."
Knowledge Check
Given a set of functional dependencies , you compute the attribute closure (with respect to ). Which condition is equivalent to ?