For a one-to-many (1:N) relationship between Parent and Child tables, where is the foreign key placed to enforce the relationship?

Difficulty: Easy

Correct Answer: the child table.

Explanation:


Introduction / Context:
One-to-many (1:N) relationships are core to relational modeling. The “many” side must reference the “one” side so that multiple children can point to the same parent while maintaining referential integrity.



Given Data / Assumptions:

  • The relationship is 1:N (for example, Customer → Orders).
  • Each child row belongs to exactly one parent row.
  • We want cascading behavior and integrity enforced in the database.


Concept / Approach:
The foreign key belongs in the child table (the N-side). It points to the parent’s primary key. This allows many child rows to reference one parent and enables DBMS enforcement of insert/update/delete rules (for example, ON DELETE RESTRICT or CASCADE).



Step-by-Step Solution:

Identify the parent (one) and child (many) tables.Add a foreign key column in the child referencing the parent’s primary key.Optionally index the foreign key for performance of joins and deletes.


Verification / Alternative check:
Attempt to insert a child with a nonexistent parent; the FK constraint should block it, confirming correct placement.



Why Other Options Are Wrong:

  • Parent table: Would imply many parents per child, which is backwards.
  • Either table / junction table: Junction tables are for many-to-many, not 1:N.
  • Either without specifying roles: Lacks necessary semantics and would not enforce 1:N properly.


Common Pitfalls:
Forgetting to add an index on the FK can slow deletions on the parent and joins. Consider ON DELETE behaviors based on business rules.



Final Answer:
the child table.

More Questions from Data Models into Database Designs

Discussion & Comments

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