Number of Possible Super Keys in DBMS | Database Management System (DBMS) - Computer Science Engineering (CSE) PDF Download

Any subset of attributes of a table that can uniquely identify all the tuples of that table is known as a Super key. Its different from the primary and candidate keys in the sense that only the minimal superkeys are the candidate/primary keys.
This means that from a super key when we remove all the attributes that are unnecessary for its uniqueness, only then it becomes a primary/candidate key. So, in essence, all primary/candidate keys are super keys but not all superkeys are primary/candidate keys. By the formal definition of a Relation(Table), we know that the tuples of a relation are all unique. So the set of all attributes itself is a super key.
Counting the possible number of superkeys for a table is a common question for GATE. The examples below will demonstrate all possible types of questions on this topic.

  • Example-1: Let a Relation R have attributes {a1, a2, a3} & a1 is the candidate key. Then how many super keys are possible?
    Here, any superset of a1 is the super key.
    Super keys are = {a1, a1 a2, a1 a3, a1 a2 a3}
    Thus we see that 4 Super keys are possible in this case.
    In general, if we have ‘N’ attributes with one candidate key then the number of possible superkeys are 2(N – 1).
  • Example-2: Let a Relation R have attributes {a1, a2, a3,…,an}. Find Super key of R.
    Maximum Super keys = 2n – 1.
    If each attribute of relation is candidate key.
  • Example-3: Let a Relation R have attributes {a1, a2, a3,…,an} and the candidate key is “a1 a2 a3” then the possible number of super keys?
    Following the previous formula, we have 3 attributes instead of one. So, here the number of possible superkeys are 2(N-3).
  • Example-4: Let a Relation R have attributes {a1, a2, a3,…,an} and the candidate keys are “a1”, “a2” then the possible number of super keys?
    This problem now is slightly different since we now have two different candidate keys instead of only one. Tackling problems like these is shown in the diagram below:
    Number of Possible Super Keys in DBMS | Database Management System (DBMS) - Computer Science Engineering (CSE)→ |A1 ∪ A2| = |A1| + |A2| – |A ∩ A2|
    = (superkeys possible with candidate key A1) + (superkeys possible with candidate key A2)
    – (common superkeys from both A1 and A2)
    = 2(n - 1) + 2(n - 1) – 2(n - 2)
  • Example 5: Let a Relation R have attributes {a1, a2, a3,…,an} and the candidate keys are “a1”, “a2 a3” then the possible number of super keys?
    Super keys of(a1) + Super keys of(a2 a3) – Super keys of(a1 a2 a3)
    ⇒ 2(n – 1) + 2(n – 2) – 2(n – 3)
  • Example 6: Let a Relation R have attributes {a1, a2, a3,…,an} and the candidate keys are “a1 a2”, “a3 a4” then the possible number of super keys?
    Super keys of(a1 a2) + Super keys of(a3 a4) – Super keys of(a1 a2 a3 a4)
    ⇒ 2(n – 2) + 2(n – 2) – 2(n – 4)
  • Example 7: Let a Relation R have attributes {a1, a2, a3,…,an} and the candidate keys are “a1 a2”, “a1 a3” then the possible number of super keys?

    Super keys of(a1 a2) + Super keys of(a1 a3) – Super keys of(a1 a2 a3)

    ⇒ 2(n – 2) + 2(n – 2) – 2(n – 3)

  • Example 8: Let a Relation R have attributes {a1, a2, a3,…,an} and the candidate keys are “a1”, “a2”, “a3” then the possible number of super keys?
    In this question, we have 3 different candidate keys. Tackling problems like these are shown in the diagram below.
    Number of Possible Super Keys in DBMS | Database Management System (DBMS) - Computer Science Engineering (CSE)
    → |A1 ∪ A2 ∪ A3| = |A1| + |A2| + |A3| – |A1 ∩ A2| – |A1 ∩ A3| – |A2 ∩ A3| + |A1 ∩ A2 ∩ A3|
    = (superkeys possible with candidate key A1) + (superkeys possible with candidate key A2) + (superkeys possible with candidate key A3) – (common superkeys from both A1 and A2) – (common superkeys from both A1 and A3) – (common superkeys from both A2 and A3) + (common superkeys from both A1, A2 and A3)
    = 2(n-1) + 2(n-1) + 2(n-1) – 2(n-2) – 2(n-2) – 2(n-2) + 2(n-3)

  • Example 9: A relation R(A, B, C, D, E, F, G, H)and set of functional dependencies are
    CH → G,
    A → BC,
    B → CFH,
    E → A,
    F → EG
    Then how many possible super keys are present ?
    Step 1: First of all, we have to find what the candidate keys are:-
    as we can see in given functional dependency D is missing but in relation, D is given so D must be a prime attribute of the Candidate key.
    A+ = E+ = B+ = F+ = all attributes of a relation except D
    So, Ck’s are = AD, BD, ED, FD
    Step 2: Find superkeys due to single candidate key
    there is a two possibility of attribute either we select or not hence there will be 2 chances so,
    A_ _D_ _ _ _ = _ B_ D_ _ _ _ = _ _ _ DE _ _ _ = _ _ _ D_F_ _ = 26
    Step 3: Find superkeys due to combination of two CK’s
    so,
    n(AD ∩ BD) = n(AD ∩ ED) = n(AD ∩ FD) = n(BD ∩ ED) = n(BD ∩ FD) = n(ED ∩ FD) = 25
    Step 4: Find supekeys due to combination of three CK’s
    so,
    n(AD ∩ BD ∩ ED) = n(AD ∩ ED ∩ FD) = n(ED ∩ BD ∩ FD) = n(BD ∩ FD ∩ AD) = 24
    Step 5: Find superkeys due to all so,
    n(AD ∩ BD ∩ ED ∩ FD) = AB_DEF_ _ = 23
    so according to inclusion- exclusion principle :-
    |W ∪ X ∪ Y ∪ Z| = |W| + |X| + |Y| + |Z| – |W ∩ X| – |W ∩ Y| – |W ∩ Z| – |X ∩Y| – |X ∩ Z| – |Y ∩ Z| + |W ∩ X ∩ Y| + |W ∩ X ∩ Z| + |W ∩ Y ? Z| + |X ∩ Y ∩ Z| – |W ∩ X ∩ Y ∩ Z|
    #Supekeys = 4 * 26 – 6 * 25 + 4 * 24 – 23 = 120

The document Number of Possible Super Keys in DBMS | Database Management System (DBMS) - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Database Management System (DBMS).
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
62 videos|66 docs|35 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Number of Possible Super Keys in DBMS - Database Management System (DBMS) - Computer Science Engineering (CSE)

1. What is a superkey in DBMS?
A superkey in DBMS is a set of one or more attributes that can uniquely identify a record in a database table. It is a superset of a candidate key and may contain additional attributes. A superkey can have more attributes than necessary to uniquely identify a record.
2. How many possible superkeys can exist in DBMS?
The number of possible superkeys in DBMS depends on the number of attributes in a table. For a table with n attributes, there can be 2^n possible superkeys. This is because each attribute can either be included or excluded from a superkey, resulting in 2 possibilities for each attribute.
3. What is the difference between a superkey and a candidate key in DBMS?
A superkey is a set of attributes that can uniquely identify a record in a table, while a candidate key is a minimal superkey that does not contain any redundant attributes. In other words, a candidate key is a superkey without any unnecessary attributes. Each table can have multiple superkeys, but only one candidate key can be chosen as the primary key.
4. How can superkeys be used in database design?
Superkeys play a crucial role in database design by helping to identify and define the relationships between tables. They can be used to establish primary key constraints, ensure data integrity, and facilitate efficient querying and indexing. By selecting the appropriate superkeys as candidate keys, designers can create an efficient and well-structured database schema.
5. Can a table have multiple candidate keys?
Yes, a table can have multiple candidate keys. These are alternate keys that can be chosen as the primary key for the table. Each candidate key must satisfy the uniqueness and minimality criteria, meaning it should uniquely identify a record and not have any redundant attributes. The choice of the primary key among the candidate keys depends on factors such as simplicity, stability, and efficiency in data retrieval.
62 videos|66 docs|35 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Semester Notes

,

video lectures

,

Previous Year Questions with Solutions

,

Sample Paper

,

Objective type Questions

,

Viva Questions

,

Free

,

Number of Possible Super Keys in DBMS | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

Number of Possible Super Keys in DBMS | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

shortcuts and tricks

,

MCQs

,

pdf

,

mock tests for examination

,

Important questions

,

study material

,

Number of Possible Super Keys in DBMS | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

Extra Questions

,

Summary

,

ppt

,

Exam

,

practice quizzes

,

past year papers

;