
Answer-first summary for fast verification
Answer: Implement a bridge table, also known as a junction table, that contains foreign keys referencing the primary keys of both 'Authors' and 'Books' tables to accurately represent the many-to-many relationship.
The correct approach to handle a many-to-many relationship between 'Authors' and 'Books' is to implement a bridge table. This table serves as an intermediary that contains foreign keys referencing the primary keys of both related tables. This method accurately represents the many-to-many relationship, allowing for multiple authors per book and multiple books per author, while ensuring data integrity and facilitating efficient queries. Other options either do not accurately represent the relationship or place unnecessary complexity on the application layer.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You are designing a semantic model for a library management system that includes 'Authors' and 'Books' tables. The system must support a scenario where an author can write multiple books, and a book can have multiple authors, establishing a many-to-many relationship. Considering the need for scalability, performance, and accurate representation of data relationships, which of the following approaches is the BEST to implement this relationship? (Choose one option)
A
Directly create a many-to-many relationship between 'Authors' and 'Books' without any intermediary table, relying on the database engine to handle the complexity.
B
Create two separate one-to-many relationships, one from 'Authors' to 'Books' and another from 'Books' to 'Authors', to simulate the many-to-many relationship.
C
Implement a bridge table, also known as a junction table, that contains foreign keys referencing the primary keys of both 'Authors' and 'Books' tables to accurately represent the many-to-many relationship.
D
Avoid implementing any relationship between 'Authors' and 'Books' to simplify the model, and manage the relationship logic in the application layer.
No comments yet.