Candidates Key for Normalization

Question 1 : Find all the possible candidate keys

Relation (A, B, C, D, E)

  • Below are the functional dependencies
    • A –> C
    • C –> D
    • D –> B
    • E –> F
  • Calculating Closure
    • Items which are not present in right side of Functional dependencies i.e A and E we will start with that, if A and E if not enough to find all the elements of the relation then we will add new attributes to find candidate keys, if A and E by them self can find all the attributes of the relation then we can say that we have only 1 candidate key
    • (AE)+ = AECDBF
    • So AE is the only candidate key for this relation

Question 2 : Find all the possible candidate keys

Relation (A, B , C , D, E, F, G, H)

  • Functional Dependencies
    • CH –> G
    • A –> BC
    • B –> CFH
    • E –> A
    • F –> EG

Calculating Closure

  • Items which are not present in right side of Functional dependencies is D, we will find D close and see if it is a candidate key, if not then we will keep adding one element at a time from the left side of functional dependencies to create candidate keys
  • (D)+ = D –> D Closure Not a candidate key
  • (DA)+ = DABCFHEG –> DA Closure is a candidate key
  • (DB)+ = DBCFHGEA –> DB Closure is a candidate key
  • (DC)+ = DC –> DC Closure not a candidate key
  • (DE)+ = DEA –> Since DA is already a candidate key hence DE closure is a candidate key
  • (DF)+ = DFEG –> Since DE is already a candidate key hence DF closure is a candidate key
  • So all the candidate keys are
    • DA, DB, DE, DF
  • Calculating prime and not prime attributes
    • Prime Attributes : If a attribute is a part of any of the candidate key it is a prime attribute in above example : ABDEF are the prime attributes and CGH are non prime attributes
    • So you want to put the relation in 2NF it would be like
      • R1(A, B, D, E, F)
      • R2(B ,C ,H ,G) SInce B –>CFH and CH–> G

  • By Definition you are part of any of the candidates key then you are a prime-attribute, other attributes which are not part of prime-attribute in a relation you call it a non prime attribute

Reference :

Example 1 (Simple)
Example 2 (Complex)

Leave a Comment