Home Dbms Tutorials Closure in DBMS | How to Find Closure

Closure in DBMS | How to Find Closure

by anupmaurya
4 minutes read

In this article, you’ll learn about Closure in DBMS and how to Find Closure

Closure of an Attribute Set-

  • The set of all those attributes which can be functionally determined from an attribute set is called as a closure of that attribute set.
  • Closure of attribute set {X} is denoted as {X}+.

Steps to Find Closure of an Attribute Set-

Following steps are followed to find the closure of an attribute set-

Step 1:

Add the attributes contained in the attribute set for which closure is being calculated to the result set.

Step 2:

Recursively add the attributes to the result set which can be functionally determined from the attributes already contained in the result set.

Example-

Consider a relation R ( A , B , C , D , E , F , G ) with the functional dependencies-

 A → BC
 BC → DE
 D → F
 CF → G 

Now, let us find the closure of some attributes and attribute sets-

Closure of attribute A-

 A+ = { A }
 = { A , B , C } ( Using A → BC )
 = { A , B , C , D , E } ( Using BC → DE )
 = { A , B , C , D , E , F } ( Using D → F )
 = { A , B , C , D , E , F , G } ( Using CF → G )
 Thus,
 A+ = { A , B , C , D , E , F , G } 

Closure of attribute D-

 D+ = { D }
 = { D , F } ( Using D → F )
 We can not determine any other attribute using attributes D and F contained in the result set.
 Thus,
 D+ = { D , F } 

Closure of attribute set {B, C}-

 { B , C }+= { B , C }
 = { B , C , D , E } ( Using BC → DE )
 = { B , C , D , E , F } ( Using D → F )
 = { B , C , D , E , F , G } ( Using CF → G )
 Thus,
 { B , C }+ = { B , C , D , E , F , G } 

Finding the Keys Using Closure-

Super Key-

  • If the closure result of an attribute set contains all the attributes of the relation, then that attribute set is called as a super key of that relation.
  • Thus, we can say-

“The closure of a super key is the entire relation schema.”

Example-

In the above example,

  • The closure of attribute A is the entire relation schema.
  • Thus, attribute A is a super key for that relation.

Candidate Key-

  • If there exists no subset of an attribute set whose closure contains all the attributes of the relation, then that attribute set is called as a candidate key of that relation.

Example-

In the above example,

  • No subset of attribute A contains all the attributes of the relation.
  • Thus, attribute A is also a candidate key for that relation.

You may also like

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.