Relational database keys: Which option best defines a foreign key in the context of relational schema design and referential integrity?

Difficulty: Easy

Correct Answer: An attribute that serves as the primary key of another relation

Explanation:


Introduction / Context:
Foreign keys are crucial for enforcing referential integrity between related tables. They ensure that every child row points to a valid parent row, which preserves consistency and prevents orphaned records in relational databases.



Given Data / Assumptions:

  • We have at least two relations (tables) with a logical parent–child relationship.
  • The parent relation has a primary key that uniquely identifies each row.
  • The child relation stores a reference to that parent key.


Concept / Approach:

A foreign key is an attribute (or set of attributes) in the child relation whose values must match existing values of the parent relation’s primary key. This constraint enforces valid references and is central to normalized design.



Step-by-Step Solution:

Identify the parent relation and its primary key (for example, Customer(customer_id)).Place the foreign key in the child relation (for example, Orders(customer_id)).Define the foreign key constraint so Orders.customer_id references Customer.customer_id.


Verification / Alternative check:

Try inserting a child row with a non-existent parent key; the database should reject it. Deleting a parent may require cascading or restriction to preserve integrity.



Why Other Options Are Wrong:

Any attribute: too vague; not all attributes are foreign keys.

Same as primary key: different concepts; one enforces identity, the other enforces reference.

Serves no purpose: incorrect; foreign keys are essential for data integrity.



Common Pitfalls:

Mismatched data types between PK and FK, missing indexes on foreign keys, and failing to handle deletes/updates appropriately.



Final Answer:

An attribute that serves as the primary key of another relation

More Questions from Logical Database Design

Discussion & Comments

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