Difficulty: Medium
Correct Answer: A primary key is also a candidate key
Explanation:
Introduction / Context:
Relational databases use different types of keys to uniquely identify rows and to establish relationships between tables. Understanding the definitions of candidate keys, primary keys, alternate keys, and foreign keys is essential for designing correct schemas and for answering conceptual questions in database examinations. This question presents several statements about keys and asks you to identify the one that is true according to standard relational theory.
Given Data / Assumptions:
Concept / Approach:
A candidate key is any minimal set of attributes that can uniquely identify a tuple in a relation. There may be several candidate keys in a table. One of these candidate keys is selected as the primary key. The remaining candidate keys that are not chosen as primary keys are called alternate keys. A foreign key is an attribute in one relation that refers to the primary key of another relation; it may or may not allow nulls depending on the design. Therefore, the definition that states a primary key is also a candidate key is correct, because the primary key is chosen from the set of candidate keys.
Step-by-Step Solution:
Step 1: Examine statement A: A primary key is also a candidate key. Since a primary key is selected from candidate keys, it remains a candidate key by definition, so this statement is true.
Step 2: Examine statement B: Each relation must have at least one foreign key. This is false, because many tables do not reference any other table and therefore have no foreign key.
Step 3: Examine statement C: Foreign keys can never contain null values. This is false in standard SQL, where foreign key columns may be nullable unless explicitly defined as NOT NULL.
Step 4: Examine statement D: A primary key is also an alternate key. This is false, because alternate keys are candidate keys that were not chosen as the primary key.
Step 5: Conclude that statement A is the only correct statement among the options.
Verification / Alternative check:
Database design textbooks typically introduce the concepts in a clear order: first candidate keys as all minimal unique identifiers, then primary key as one selected candidate key, and alternate keys as the remaining candidate keys. They explicitly state that primary keys and alternate keys are both candidate keys, differing only by whether they have been chosen to serve as the main identifier. Additionally, they explain that foreign keys may allow nulls to represent optional relationships. This confirms that statement A is true and that B, C, and D are false.
Why Other Options Are Wrong:
Each relation must have at least one foreign key: This is wrong because some tables are root tables that do not reference any other table and therefore have no foreign keys at all.
Foreign keys can never contain null values: This is wrong because many database systems permit foreign key columns to be nullable, allowing for optional relationships between rows.
A primary key is also an alternate key: This is wrong because alternate keys are candidate keys that are not selected as the primary key. The primary key and alternate keys are disjoint subsets of the candidate keys.
Common Pitfalls:
Learners often mix up the terminology candidate key, primary key, and alternate key because they all relate to uniqueness. Another frequent mistake is to assume that foreign keys must always be non-null, when in fact optional relationships are commonly modelled with nullable foreign keys. To avoid confusion, remember that candidate keys are the pool of possible unique identifiers, the primary key is the chosen one from that pool, and alternate keys are the remaining candidates.
Final Answer:
The true statement is that A primary key is also a candidate key.
Discussion & Comments