DEV Community

Cover image for Finding Super Keys
hebaShakeel
hebaShakeel

Posted on

Finding Super Keys

How to find a Super Key in a Relation

Consider a relation R(a1, a2, a3,.....an), where n = number of attributes in a relation.
Suppose Candidate Key = (a1)
Find total SKs.

No. of Super Keys = 2^(n-1)

Example 1
R(ABCDE), CK={B}
Find total SKs

Here n = 5
n-1 = 4
Therefore total number of SKs = 2^4 = 16

Example 2
R(a1, a2, a3,....an), CK={a1a2}
Find total SKs

No. of Super Keys = 2^(n-2), since here there are 2 attributes in the candidate Key.

Example 3
R(XYZMN), CK={ZM}
Find total SKs

Here n = 5
No. of attributes in Candidate Key = 2
Therefore total number of SKs = 2^(5-2) = 2^3 = 8

Example 4
R(a1, a2, a3,....an), CK={a1,a2}
Find total SKs

All SKs which have either a1 or a2 or a1a2
n(a1 U a2) = n(a1) + n(a2) - n(a1a2)

Therfore No. of Super Keys = 2^(n-1) + 2^(n-1) - 2^(n-2)

Example 4
R(A,B,C,D,E,F), CK={A,DF}
Find total SKs

Total number of SKs = 2^(6-1) + 2^(6-2) - 2^(6-3) = 32+16-8 = 40

Top comments (0)