Choosing a key: A list has last names, first names, addresses, and PIN codes. If all people share the same last name and the same PIN code, which key would be most useful to distinguish records?

Difficulty: Easy

Correct Answer: A compound key consisting of the first name and the last name

Explanation:


Introduction / Context:
Keys uniquely identify records. When some attributes are identical across many rows, you must choose a key (or combination) that remains unique to ensure reliable lookups and updates.



Given Data / Assumptions:

  • All entries share the same last name.
  • All entries share the same PIN code.
  • First names vary across the entries.


Concept / Approach:
Neither last name nor PIN code can distinguish rows if they are identical across the set. A compound (composite) key uses two or more attributes together. If last name is constant, combining it with first name typically yields uniqueness across individuals in the list.



Step-by-Step Solution:

Eliminate attributes that are constant (last name, PIN code).Consider combinations that can vary: first name + last name.Select the composite key that best supports uniqueness and indexing.


Verification / Alternative check:
Attempt to find duplicates using the composite: SELECT first_name, last_name, COUNT() FROM People GROUP BY first_name, last_name HAVING COUNT() > 1. If none exist, the pair is a valid key for this dataset.



Why Other Options Are Wrong:

  • The last name: identical across all rows—non-unique.
  • The PIN code: identical across all rows—non-unique.
  • All of the above: false since single attributes listed are not unique.


Common Pitfalls:
Assuming a single attribute must be the key; in many practical scenarios, composite keys are essential.



Final Answer:
A compound key consisting of the first name and the last name

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion