Final answer:
Option b) is the correct design for a MongoDB schema to handle a many-to-many relationship between orders and products.
Step-by-step explanation:
Option b) is the correct design for a MongoDB schema to handle a many-to-many relationship between orders and products. Creating a 3rd collection that contains documents with fields corresponding to an order_id and the ID of a product appearing in that order allows for efficient querying and retrieval of data.
The other options have drawbacks:
- Option a) stores all the product IDs within the order document, which can lead to inefficient querying and difficulty in retrieving specific information.
- Option c) suggests using a relational database instead of MongoDB, which would involve changing the entire database system, creating more complexity and potential migration difficulties.
- Option d) proposes creating a separate collection for each order and product combination, which would lead to a large number of collections and complicated querying.