A · Compressed recap
A superkey has no two tuples agreeing on it in any valid state; all attributes form one, and supersets of superkeys are superkeys. A candidate key is a minimal superkey; the primary key is the chosen one (never NULL); others are alternate keys; an attribute in some candidate key is prime. An instance can disprove but never prove a key. Superkeys: 2ⁿ⁻ᵏ for one key of k attributes; inclusion–exclusion for several; max candidate keys C(n, ⌊n/2⌋).
A foreign key in the referencing relation must match a primary key value in the referenced relation or be NULL. Names may differ; FKs may repeat, may be NULL, may reference their own relation and may be part of the PK.
B · Merged rule card
2.2.1 Superkey, candidate key, primary key, alternate key; counting superkeys
- Superkey: no two tuples in any valid state agree on it; all attributes form a superkey; supersets of superkeys are superkeys.
- Candidate key = minimal superkey; may be composite; several may exist.
- Primary key = chosen candidate key, never NULL; others = alternate keys. Prime attribute = in some candidate key.
- Instance disproves, never proves, a key.
- Superkeys with one key of k attributes: 2ⁿ⁻ᵏ. Two keys: 2ⁿ⁻|K₁| + 2ⁿ⁻|K₂| − 2ⁿ⁻|K₁∪K₂|.
- Max candidate keys for n attributes: C(n, ⌊n/2⌋).
2.2.2 Foreign key; referencing vs referenced relations
- FK in R₁ references PK of R₂: every FK value equals some PK value in R₂, or is NULL.
- R₁ referencing (child), R₂ referenced (parent); arrow from FK to PK.
- Names may differ; domains must match.
- Several FKs per relation; self-referencing FKs allowed; an FK may be part of the PK (then it cannot be NULL).
- FK values may repeat; referenced values may be unused.
C · Interleaved GATE-style questions
Q1 · NAT · 2 mark(s) — Superkeys
R(A, B, C, D, E) has candidate keys {A} and {B, C}. How many superkeys?
Numerical answer: ________
Q2 · NAT · 2 mark(s) — Superkeys
R(A, B, C) has candidate keys {A}, {B} and {C}. How many superkeys?
Numerical answer: ________
Q3 · MCQ · 1 mark(s) — Keys
Which statement is always true?
- (A) Every superkey is a candidate key.
- (B) A primary key may contain NULL.
- (C) A relation has exactly one candidate key.
- (D) Every candidate key is a superkey.
Q4 · MCQ · 2 mark(s) — Instance
Instance of R(A, B, C): (1, 2, 3), (1, 3, 3), (2, 2, 4). Which can still be a candidate key?
- (A) {A}
- (B) {B}
- (C) {C}
- (D) {A, B}
Q5 · MSQ · 2 mark(s) — Foreign keys
EMP(eid, name, manager) with manager → EMP.eid. Which are valid together in one state?
- (A) (3, Kiran, 9) where no employee 9 exists
- (B) (2, Meena, 1)
- (C) (1, Ravi, NULL)
- (D) (4, Lata, 2)
Q6 · MCQ · 1 mark(s) — Foreign keys
A foreign key must reference:
- (A) a primary key (or declared unique key) of the referenced relation
- (B) any attribute of any relation
- (C) an attribute with the same name
- (D) a non-key attribute
Q7 · NAT · 1 mark(s) — Max keys
What is the maximum number of candidate keys of a relation with 6 attributes?
Numerical answer: ________
Q8 · MCQ · 1 mark(s) — Alternate keys
EMP has candidate keys {eid}, {pan}, {email}. eid is chosen as primary key. How many alternate keys are there?
- (A) 2
- (B) 3
- (C) 1
- (D) 0
D · Answer Vault
Reveal answers when you’re ready
Q1 Answer: 20 · 2 mark(s)
Contain A: 2⁴ = 16. Contain BC: 2³ = 8. Contain ABC: 2² = 4. 16 + 8 − 4 = 20.
Re-read: Lesson 2.2.1 — Superkey, candidate key, primary key, alternate key; counting superkeys
Q2 Answer: 7 · 2 mark(s)
Every non-empty subset contains A, B or C: 2³ − 1 = 7.
Re-read: Lesson 2.2.1 — Superkey, candidate key, primary key, alternate key; counting superkeys
Q3 Answer: (D) · 1 mark(s)
Candidate keys are minimal superkeys.
- (A) is wrong: Superkeys need not be minimal.
- (B) is wrong: Never.
- (C) is wrong: There may be several.
Re-read: Lesson 2.2.1 — Superkey, candidate key, primary key, alternate key; counting superkeys
Q4 Answer: (D) · 2 mark(s)
A, B and C each repeat a value, so none alone is a key. {A, B} values (1,2), (1,3), (2,2) are distinct.
- (A) is wrong: 1 repeats.
- (B) is wrong: 2 repeats.
- (C) is wrong: 3 repeats.
Re-read: Lesson 2.2.1 — Superkey, candidate key, primary key, alternate key; counting superkeys
Q5 Answer: (B) (C) (D) · 2 mark(s)
Self-referencing FK; 9 does not exist.
- (A) is wrong: Dangling reference.
Re-read: Lesson 2.2.2 — Foreign key; referencing vs referenced relations
Q6 Answer: (A) · 1 mark(s)
FK → PK.
- (B) is wrong: Must be a key.
- (C) is wrong: Names may differ.
- (D) is wrong: Must be a key.
Re-read: Lesson 2.2.2 — Foreign key; referencing vs referenced relations
Q7 Answer: 20 · 1 mark(s)
C(6, 3) = 20.
Re-read: Lesson 2.2.1 — Superkey, candidate key, primary key, alternate key; counting superkeys
Q8 Answer: (A) · 1 mark(s)
pan and email.
- (B) is wrong: The primary key is not alternate.
- (C) is wrong: Two remain.
- (D) is wrong: There are other candidate keys.
Re-read: Lesson 2.2.1 — Superkey, candidate key, primary key, alternate key; counting superkeys