Difficulty: Easy
Correct Answer: Correct
Explanation:
Introduction / Context:
Relations (tables) in a database model real-world associations: Orders belong to Customers, LineItems belong to Orders, and so on. The mechanism that enforces these associations is the foreign key constraint. This item checks your understanding of how relational links are realized technically.
Given Data / Assumptions:
Concept / Approach:
A foreign key defines and enforces the relationship between two tables. It constrains allowed values in the child table’s referencing column(s) to those that exist in the parent table’s referenced key. This enforces “existence dependency” and allows the DBMS to support ON DELETE/ON UPDATE actions like RESTRICT, CASCADE, SET NULL, or SET DEFAULT. The choice between natural and surrogate keys is orthogonal: the foreign key mechanism works for either.
Step-by-Step Solution:
Verification / Alternative check:
Attempting to insert a child referencing a non-existent parent key will fail; deleting a parent with existing children will follow configured action (RESTRICT, CASCADE, etc.).
Why Other Options Are Wrong:
Common Pitfalls:
Not indexing foreign key columns; mismatched data types or collations between parent and child; trying to enforce relationships purely in application code.
Final Answer:
Correct
Discussion & Comments