This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
A developer is designing a document schema for a product catalog where each product has technical specifications that are always displayed on the product detail page. The combined product and specifications data is approximately 5 KB. Which modeling strategy should the developer use for this relationship?
Store specifications in a separate collection and reference them by ID from the product document.
Embed the specifications as a nested object inside the product document.
Store each specification field as a separate document in a specifications collection.
An e-commerce application stores product reviews. Popular products can have over 50,000 reviews, but the product page only displays the top 10 most helpful reviews on initial load. Which pattern best models this relationship?
Embed all reviews directly in the product document.
Store all reviews in a separate collection and query the top 10 every time the product page loads.
Embed the top 10 reviews in the product document and store all reviews in a separate collection.
A developer needs to model a many-to-many relationship between products and categories. Product pages must display category names, and category pages must list products. Both queries are equally frequent. Which approach should the developer use?
Store category ID only on the product documents and use a lookup to resolve category names.
Create a junction collection with one document per product-category pair.
Store denormalized category information on product documents and product ID arrays on category documents.
When an app analyzes a one-to-many relationship between customers and orders, a developer finds that customers average 10 orders today but the application is expected to handle customers with thousands of orders within two years. Which factor in the decision framework is most critical for choosing between embedding and referencing?
Access pattern frequency
Cardinality and growth potential
Data ownership lifecycle
A retail application stores user documents with embedded addresses. A user currently has three addresses. The developer needs to update the street field of the user's home address without affecting the other addresses. Which approach correctly targets only the home address?
Use $set to replace the entire addresses array with a new array containing the updated address.
To update only the matched element, use updateOne with a query filter matching the address type and the positional operator ($).
Use $pull to remove the home address, then $push to add the updated version.
$pull
$push
You must answer all questions before checking your work.
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?