Question:medium

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: Aug 3, 2026
Show Solution

Correct Answer: 6

Solution and Explanation

We are given a relation \(R(A, B, C, D)\) whose only candidate keys are \(\{A, B\}\) and \(\{A, C\}\). The goal is to determine how many superkeys \(R\) has.

Think of it this way: a superkey is any attribute combination that is 'key enough', meaning it must fully contain at least one of the candidate keys. Since \(R\) has only 4 attributes total, there are \(2^4 = 16\) possible attribute combinations in total, but not all of them are superkeys -- only those that cover a candidate key.

Approach using the extra, non-key attributes:

Attribute \(D\) never appears in any candidate key, so \(D\) is what we call an 'extra' attribute -- it can be freely added to or left out of any superkey without affecting whether that set is minimal or not. Attribute \(A\) is common to both candidate keys, while \(B\) and \(C\) are the attributes that distinguish the two candidate keys from each other.

Now build the superkeys systematically. Any superkey must contain \(A\) together with either \(B\) or \(C\) (or possibly both), and it may or may not also contain \(D\).

Case 1: Superkey contains \(\{A, B\}\) but not \(C\). With \(D\) optional, this gives 2 combinations: \(\{A,B\}\) and \(\{A,B,D\}\).

Case 2: Superkey contains \(\{A, C\}\) but not \(B\). With \(D\) optional, this gives 2 combinations: \(\{A,C\}\) and \(\{A,C,D\}\).

Case 3: Superkey contains both \(\{A, B, C\}\) (covers both keys at once). With \(D\) optional, this gives 2 combinations: \(\{A,B,C\}\) and \(\{A,B,C,D\}\).

Adding these mutually exclusive cases: \(2 + 2 + 2 = 6\).

So the total number of superkeys of \(R\) is:

\[\boxed{6}\]

This matches the official answer range of 6 to 6.

Was this answer helpful?
0


Questions Asked in GATE CS exam