Sample questions
Question 1Easy
A minimal set of attributes that uniquely identifies every tuple in a relation is called a:
- Super key
- Foreign key
- Composite attribute
- Candidate key
Answer: D. Candidate key
Explanation
Every candidate key is a super key with no redundant attribute. One candidate key is chosen as the primary key.
Step-by-step solution
- A super key is any set of attributes that identifies tuples uniquely.
- A minimal super key, with no removable attribute, is a candidate key.
- So the answer is candidate key.
Why the other options are wrong
- A. A super key need not be minimal.
- B. A foreign key refers to another relation's key.
- C. A composite attribute is an ER concept, not a key.
Tip: Candidate key = super key with nothing extra.
Question 2Easy
Which attribute in an Employee(EmpID, Name, DeptID) table is most likely a foreign key?
- Name
- None of them
- EmpID
- DeptID
Answer: D. DeptID
Explanation
DeptID refers to the primary key of a Department table, so it is the foreign key.
Step-by-step solution
- EmpID identifies the employee: it is the primary key.
- DeptID points to a row in a Department table.
- So DeptID is the foreign key.
Why the other options are wrong
- A. Name is a descriptive attribute.
- B. DeptID refers to another table, so it is a foreign key.
- C. EmpID is the primary key of Employee.
Tip: Another entity's ID inside this table = foreign key.
Question 3Easy
A table Enrollment(StudentID, CourseID, Grade) records one grade per student per course. What is its natural primary key?
- StudentID
- CourseID
- (StudentID, CourseID)
- (CourseID, Grade)
Answer: C. (StudentID, CourseID)
Explanation
A student takes many courses and a course has many students, so only the pair identifies a row.
Step-by-step solution
- One student can have many rows (one per course), so StudentID alone repeats.
- One course has many students, so CourseID alone repeats.
- The rule is one grade per student per course, so the pair (StudentID, CourseID) never repeats.
- So the composite key (StudentID, CourseID) identifies each row.
Why the other options are wrong
- A. A student enrolled in two courses would have two rows with the same StudentID.
- B. Many students take the same course, so CourseID repeats.
- D. Two students in one course can get the same grade, so this pair can repeat.
Tip: For a junction table, the key is usually the pair of foreign keys.
Question 4Easy
Relation R(A, B, C, D) has FDs {A->B, B->C, C->D}. What is the only candidate key of R?
- A
- AB
- B
- D
Answer: A. A
Explanation
Attributes that never appear on a right side must be in every key. Here (A)+ = ABCD, which is all of R, and no proper subset of A works.
Step-by-step solution
- A never appears on a right side, so A is in every key.
- A+ = {A, B, C, D}, the whole relation.
- So A alone is the only candidate key.
Why the other options are wrong
- B. AB is a superkey, but not minimal.
- C. B+ = {B, C, D}, which misses A.
- D. D+ = {D}.
Tip: Never-on-right attributes covering everything = the only key.
Question 5Medium
If an attribute appears only on the right-hand side of FDs (never on a left side), then:
- It must be the primary key
- It cannot be NULL
- It is part of every candidate key
- It is not part of any candidate key
Answer: D. It is not part of any candidate key
Explanation
Such an attribute is determined by others and helps determine nothing, so adding it to a key is never needed for minimality.
Step-by-step solution
- The attribute is always derived from others and never derives anything.
- A minimal key drops any attribute that can be derived from the rest.
- Since this attribute can always be derived, it is never needed in a minimal key.
- So it is not part of any candidate key (it is non-prime).
Why the other options are wrong
- A. A primary key is chosen from candidate keys, and this attribute is in none of them.
- B. Nullability is a declared constraint and has nothing to do with where it sits in the FDs.
- C. That rule applies to attributes that never appear on the right side.
Tip: Only on the right side means the attribute is non-prime.
Question 6Medium
A foreign key may refer to which of the following in the parent table?
- Only the primary key, never a UNIQUE column
- Any column, unique or not
- Only an indexed non-key column
- Its primary key or another UNIQUE key
Answer: D. Its primary key or another UNIQUE key
Explanation
The referenced column set must be guaranteed unique so that each child value matches at most one parent row.
Step-by-step solution
- A foreign key must reference values that are unique in the parent.
- That can be the primary key or any UNIQUE (candidate) key.
- Non-unique columns cannot be referenced.
Why the other options are wrong
- A. UNIQUE columns can also be referenced.
- B. A non-unique column could match several parent rows.
- C. An index alone does not make values unique.
Tip: FK target = PRIMARY KEY or UNIQUE.
Question 7Medium
Deleting a row from Department fails because Employee rows still reference it. Which referential action would instead delete those Employee rows automatically?
- ON DELETE SET NULL
- ON DELETE CASCADE
- ON DELETE RESTRICT
- ON UPDATE CASCADE
Answer: B. ON DELETE CASCADE
Explanation
CASCADE propagates the delete to referencing rows; SET NULL clears the foreign key instead; RESTRICT blocks the delete.
Step-by-step solution
- The default (RESTRICT or NO ACTION) blocks the delete.
- ON DELETE CASCADE deletes the child rows that reference the parent.
- So Employee rows are removed automatically.
Why the other options are wrong
- A. SET NULL keeps the Employee rows and sets DeptID to NULL.
- C. RESTRICT is what causes the failure.
- D. ON UPDATE CASCADE applies to key changes, not deletes.
Tip: CASCADE = delete the children too; SET NULL = orphan them safely.
Question 8Medium
Relation R(A, B, C, D, E, F) has FDs {A->B, C->D, E->F}. What is the only candidate key of R?
- ABCDE
- ACE
- AC
- ACEF
Answer: B. ACE
Explanation
Attributes that never appear on a right side must be in every key. Here (ACE)+ = ABCDEF, which is all of R, and no proper subset of ACE works.
Step-by-step solution
- A, C and E never appear on a right side, so they are in every key.
- ACE+ = {A, B, C, D, E, F}.
- So ACE is the only candidate key.
Why the other options are wrong
- A. ABCDE is a superkey but not minimal.
- C. AC+ = ABCD, which misses E and F.
- D. F is extra, since E -> F.
Tip: Collect the attributes that never appear on a right side.
Question 9Hard
Relation R(A, B, C, D, E) has A as its only candidate key. How many super keys does R have?
- 5
- 16
- 32
- 31
Answer: B. 16
Explanation
A super key is any attribute set containing A.
The other 4 attributes may each be included or not:
2^4 = 16.
Step-by-step solution
- A super key is any set containing the key A.
- The other 4 attributes B, C, D, E can each be in or out.
- 2^4 = 16 super keys.
Why the other options are wrong
- A. 5 is the number of attributes, not super keys.
- C. 32 counts all subsets, including those without A.
- D. 31 counts all non-empty subsets.
Tip: One key of size k among n attributes: 2^(n-k) super keys.
Question 10Hard
R(A, B, C, D, E, F) has FDs {AB->C, C->D, D->A, E->F}. Which attributes are prime (belong to some candidate key)?
- B, E
- A, B, C, D
- A, B, E
- A, B, C, D, E
Answer: D. A, B, C, D, E
Explanation
The candidate keys are ABE, BCE, BDE, so the prime attributes are their union: A, B, C, D, E.
Step-by-step solution
- B and E never appear on a right side, so both are in every key.
- BE+ = BEF, so add one of A, C or D: ABE, BCE and BDE are keys (the cycle AB -> C -> D -> A lets them swap).
- Prime attributes: A, B, C, D, E. F is non-prime.
Why the other options are wrong
- A. B and E alone are not a key; one of A, C, D is also needed.
- B. E is in every key.
- C. C and D also appear in keys BCE and BDE.
Tip: Find all keys, then take their union.
Practise all 38 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →