Course contentsShow
← Computer Science
Lesson 1630 of 2,87237. Database Design and NormalizationFree lesson

Using FDs to Identify Candidate Keys

Applying functional dependency analysis to systematically determine all candidate keys and the primary key for a relation.

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:

  1. Start with attribute combinations – Begin with single attributes, then pairs, then triples, etc.

  2. Compute the closure – For each combination, calculate its closure using the given FDs (as you learned with closure of attribute sets).

  3. Check if it determines all attributes – If the closure includes every attribute in the relation, it's a superkey.

  4. 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? D alone gives {D} – incomplete
    • Remove D? A alone gives {A, B, C} – incomplete
    • AD is minimal → candidate key ✓
  • 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.