Question:

Consider a relational database schema with a relation 𝑅(𝐴, 𝐡, 𝐢, 𝐷). If {𝐴, 𝐡} and
{𝐴, 𝐢} are the only two candidate keys of the relation 𝑅, then the number of superkeys
of relation 𝑅 is ______. (answer in integer)

Show Hint

A superkey must contain at least one candidate key. Count subsets of \{A,B,C,D\} containing \{A,B\} or \{A,C\} using inclusion-exclusion: \(4 + 4 - 2 = 6\), since D is a free non-key attribute.
Updated On: Jul 7, 2026
Show Solution
collegedunia
Verified By Collegedunia

Correct Answer: 6

Solution and Explanation

A relation \(R(A, B, C, D)\) has candidate keys \(\{A, B\}\) and \(\{A, C\}\). We need to count the total number of superkeys of \(R\).

Step 1: Recall the definition of a superkey.

A superkey is any subset of attributes of \(R\) that contains at least one candidate key as a subset. Since \(R\) has 4 attributes, the total number of possible attribute subsets is \(2^4 = 16\). We must find how many of these 16 subsets contain \(\{A, B\}\) or contain \(\{A, C\}\).

Step 2: Count subsets containing candidate key \(\{A, B\}\).

If a subset must contain \(A\) and \(B\), the remaining attributes \(\{C, D\}\) can each be independently present or absent. This gives \(2^2 = 4\) subsets:

\[\{A,B\},\ \{A,B,C\},\ \{A,B,D\},\ \{A,B,C,D\}\]

Step 3: Count subsets containing candidate key \(\{A, C\}\).

Similarly, if a subset must contain \(A\) and \(C\), the remaining attributes \(\{B, D\}\) can each be independently present or absent, giving \(2^2 = 4\) subsets:

\[\{A,C\},\ \{A,B,C\},\ \{A,C,D\},\ \{A,B,C,D\}\]

Step 4: Apply the principle of inclusion-exclusion.

Some subsets appear in both lists (they contain both \(\{A,B\}\) and \(\{A,C\}\), i.e. they contain \(\{A,B,C\}\)). With \(D\) free to be present or absent, there are \(2^1 = 2\) such overlapping subsets: \(\{A,B,C\}\) and \(\{A,B,C,D\}\).

Using inclusion-exclusion, the total number of distinct superkeys is:

\[|S_{AB} \cup S_{AC}| = |S_{AB}| + |S_{AC}| - |S_{AB} \cap S_{AC}| = 4 + 4 - 2 = 6\]

Step 5: List all superkeys to verify.

\[\{A,B\},\ \{A,C\},\ \{A,B,C\},\ \{A,B,D\},\ \{A,C,D\},\ \{A,B,C,D\}\]

This confirms exactly 6 superkeys.

Final Answer:

\[\boxed{6}\]

Was this answer helpful?
0
0

Top GATE CS Computer Science and IT Engineering Questions

View More Questions

Top GATE CS Functional Dependency Questions