SQL - Table RelationshipsWhich of the following is the correct way to represent a one-to-many relationship in tables derived from an ER diagram?ACreate a new table with only primary keys from both tablesBAdd a foreign key column in the 'many' side table referencing the 'one' sideCAdd a foreign key column in the 'one' side table referencing the 'many' sideDUse a trigger to link the two tablesCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand one-to-many relationshipOne-to-many means one record in the first table relates to many records in the second table.Step 2: Map relationship to tablesThe 'many' side table gets a foreign key column referencing the 'one' side table's primary key.Final Answer:Add a foreign key column in the 'many' side table referencing the 'one' side -> Option BQuick Check:Foreign key on 'many' side = Add a foreign key column in the 'many' side table referencing the 'one' side [OK]Quick Trick: Foreign key goes in the 'many' side table [OK]Common Mistakes:MISTAKESPlacing foreign key on the 'one' sideCreating unnecessary tables for one-to-manyUsing triggers instead of foreign keys
Master "Table Relationships" in SQL9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More SQL Quizzes Advanced Joins - CROSS JOIN cartesian product - Quiz 8hard LEFT and RIGHT JOIN - Why outer joins are needed - Quiz 2easy LEFT and RIGHT JOIN - LEFT JOIN preserving all left rows - Quiz 6medium LEFT and RIGHT JOIN - LEFT JOIN with NULL result rows - Quiz 1easy Set Operations - INTERSECT for common rows - Quiz 13medium Subqueries - Subquery in FROM clause (derived table) - Quiz 4medium Subqueries - Correlated subquery execution model - Quiz 2easy Views - Updatable views and limitations - Quiz 11easy Views - Updatable views and limitations - Quiz 2easy Views - Why views are needed - Quiz 14medium