Hamish Burke | 2025-05-22

Related to: #databases


Attribute Closure

Compute X

  1. Initialise X=X
  2. For each FD YZ in F, if YX then add Z to X
  3. Repeat until no new attributes can be added

X is a superkey is X contains all attributes, a candidate key if X is a superkey and no proper subset of X is a superkey

Example

R(A,B,C,D), F{AB->C,C->D}

Compute {A,B}

  1. Start with {A,B}
  2. For AB->C, AB is a subset of {A,B}, so add C
  3. Now its {A,B,C}
  4. For C->, C is a subset of {A,B,C}, so add D
  5. Now its {A,B,C,D}
  6. Nothing else would make it grow, so stop
  7. {A,B}={A,B,C,D}

Compute {A}

  1. Start with {A}
  2. For AB->C, AB is not a subset of A, do nothing
  3. For C->D, C is not a subset of A, do nothing
  4. {A}={A}