Using FDs to Identify Candidate Keys
What you'll learn: How to systematically apply functional dependency analysis to find all candidate keys in a relation.
Why This Matters
You've learned about functional dependencies (FDs) and attribute closures. Now we put them to work solving a fundamental question: What are all the possible keys for this relation? A candidate key is a minimal set of attributes that uniquely identifies every tuple, and finding them ensures proper database design.
The Process
To identify candidate keys using FDs:
-
Start with attribute combinations – Begin with single attributes, then pairs, then triples, etc.
-
Compute the closure – For each combination, calculate its closure using the given FDs (as you learned with closure of attribute sets).
-
Check if it determines all attributes – If the closure includes every attribute in the relation, it's a superkey.
-
Verify minimality – Remove one attribute at a time. If any subset is also a superkey, the original isn't minimal (not a candidate key).
Example Walkthrough
Given relation R(A, B, C, D) with FDs: A → B, B → C, CD → A
- Try
A: Closure is{A, B, C}– not all attributes, so not a key - Try
AD: Closure is{A, D, B, C}– all attributes! It's a superkey- Remove
A?Dalone gives{D}– incomplete - Remove
D?Aalone gives{A, B, C}– incomplete - AD is minimal → candidate key ✓
- Remove
- Try
CD: Closure is{C, D, A, B}– all attributes! Also minimal → candidate key ✓
Both AD and CD are candidate keys. You'd pick one as the primary key.
Key Takeaway: Use attribute closure to test whether attribute sets determine all attributes, then verify minimality by removing attributes one at a time—only minimal superkeys qualify as candidate keys.