[{"id":"mongodbintermediate-001","courseId":"mongodb-intermediate","domain":"data-modeling","topic":"Bucket pattern","prompt":"Your app shows product reviews 10 per page. Which TWO design choices use the bucket pattern for those reviews?","hint":"Think about where the paging work happens and how many documents hold the reviews.","source":"https://www.mongodb.com/docs/manual/data-modeling/design-patterns/group-data/","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"Split the large review series into several smaller series instead of one long list","why":"Grouping a large series into multiple smaller series can improve performance, which is the core idea of the bucket pattern."},{"id":"b","text":"Put all reviews in one array on the product document","whyNot":"One growing array is not a bucket. Buckets split the series into groups, so no single document holds everything."},{"id":"c","text":"Let the server return each page, so the app does less paging work","why":"The bucket pattern handles pagination on the server, which reduces application workload and simplifies paging logic."},{"id":"d","text":"Store each review as its own document and sort them in the app","whyNot":"That leaves the work in the application, the opposite of what bucketing is meant to reduce."}],"answer":"ac","explanation":"The bucket pattern groups a large series of data into multiple smaller series, and handles pagination on the server so the application does less work.","concept":"The bucket pattern groups a large series of data into multiple smaller series, and handles pagination on the server so the application does less work.","rev":1,"kind":"scenario","takeaways":["Group a large series into smaller series and let the server handle pagination, so the app does less work."]},{"id":"mongodbintermediate-002","courseId":"mongodb-intermediate","domain":"data-modeling","topic":"Outlier pattern","prompt":"Most books have a few reviews, but one new title gets thousands. Storing every review inside each book document makes that one document huge. What does the outlier pattern suggest?","hint":"The problem is one oversized document hurting the rest of the collection.","source":"https://www.mongodb.com/docs/manual/data-modeling/design-patterns/group-data/","interaction":{"type":"single"},"options":[{"id":"a","text":"Move the popular book's reviews into separate documents, so no one document grows large","why":"The outlier pattern separates the popular book's reviews into their own documents, so typical books keep small documents."},{"id":"b","text":"Raise the document size limit so the popular book's reviews fit in one document","whyNot":"One large document still disrupts retrieval for typical documents. The outlier pattern avoids that by splitting the data."},{"id":"c","text":"Delete the reviews beyond the first hundred to keep the book document small","whyNot":"The pattern separates data rather than discarding it, so no reviews are lost."},{"id":"d","text":"Keep all reviews inside the book document, since one read is always cheapest","whyNot":"The outlier pattern exists because one large document disrupts retrieval for smaller, typical documents."}],"answer":"a","explanation":"The outlier pattern moves a few unusually large sets of data into separate documents, so typical documents stay small and fast to retrieve.","concept":"The outlier pattern moves a few unusually large sets of data into separate documents, so typical documents stay small and fast to retrieve.","rev":1,"kind":"scenario","takeaways":["Handle outliers apart from typical data so one oversized document doesn't slow retrieval for the rest."]},{"id":"mongodbintermediate-003","courseId":"mongodb-intermediate","domain":"data-modeling","topic":"Computed pattern","prompt":"A site shows a '100 Best-Reviewed Gadgets' list. The underlying reviews change all day, and the list is read far more often than it changes. Which design fits the computed pattern?","hint":"Ask when the calculation should run: at read time or ahead of it.","source":"https://www.mongodb.com/docs/manual/data-modeling/design-patterns/handle-computed-values/","interaction":{"type":"single"},"options":[{"id":"a","text":"Store the ranked list as its own document, and refresh it with a periodic task","why":"The computed pattern pre-computes values and stores them, so reads return the stored list instead of recalculating."},{"id":"b","text":"Sort the reviews in the application on every page request, so the list is never stale","whyNot":"That recalculates the ranking at read time, the cost the computed pattern moves ahead of the request."},{"id":"c","text":"Use the approximation pattern, since a ranked list can be wrong by design","whyNot":"Approximation trades precision for speed and is used for values like population counts, not as a reason to skip precomputing."},{"id":"d","text":"Recompute the list inside the database on each read, so results are always exact","whyNot":"Computing on each read is the request-time work the computed pattern avoids by storing results ahead of time."}],"answer":"a","explanation":"The computed pattern runs calculations ahead of time, on insert or with a periodic task, and stores the result so reads return it directly.","concept":"The computed pattern runs calculations ahead of time, on insert or with a periodic task, and stores the result so reads return it directly.","rev":1,"kind":"scenario","takeaways":["Precompute a value when its inputs change slowly or on a schedule, and store it for fast reads."]},{"id":"mongodbintermediate-004","courseId":"mongodb-intermediate","domain":"data-modeling","topic":"Archive pattern","prompt":"Your sales collection holds years of orders. Archived sales must return complete order details in one query. Which TWO choices follow the archive pattern guidance?","hint":"Think about where related data should live and how many fields should hold the age.","source":"https://www.mongodb.com/docs/manual/data-modeling/design-patterns/archive/","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"Embed each sale's products inside the archived sale document, not reference another collection","why":"Archived data should use an embedded model, so a query returns all related components together."},{"id":"b","text":"Keep product details as references to the live products collection, so prices stay current","whyNot":"Archived data should avoid references to other collections, since they can pull in data from a different time."},{"id":"c","text":"Store the sale's age in one date field that the archive job checks","why":"The document's age should be contained in a single field, so the archive rule has one value to check."},{"id":"d","text":"Track age in both a date field and a separate year field, so either can filter archives","whyNot":"The age should live in a single field. Two age fields can disagree and make archive decisions unreliable."}],"answer":"ac","explanation":"Archived data should be embedded so queries return related data from the same time together, and the document's age should live in a single field.","concept":"Archived data should be embedded so queries return related data from the same time together, and the document's age should live in a single field.","rev":1,"kind":"scenario","takeaways":["Embed archived data and keep one age field, so each archived document is self-contained."]},{"id":"mongodbintermediate-005","courseId":"mongodb-intermediate","domain":"data-modeling","topic":"Polymorphic pattern","prompt":"Your app lists all athletes in one query, but each sport stores different fields, such as goals for soccer and lap times for swimming. What does the polymorphic pattern suggest?","hint":"Think about whether documents in one collection have to share the same fields.","source":"https://www.mongodb.com/docs/manual/data-modeling/design-patterns/polymorphic-data/","interaction":{"type":"single"},"options":[{"id":"a","text":"Keep all athletes in one collection, since one query can return documents with different shapes","why":"The polymorphic pattern groups documents with different fields in one collection so a single query can reach them all."},{"id":"b","text":"Create one collection per sport and query each collection separately","whyNot":"That splits the athletes by shape, so the single query the pattern allows is lost."},{"id":"c","text":"Add every sport's fields to every athlete, so all documents match one shape","whyNot":"Polymorphic data is data that varies in fields and types, so forcing one shape is not what the pattern asks for."},{"id":"d","text":"A collection must hold documents of one shape, so athletes of other sports need a new collection","whyNot":"MongoDB's flexible model lets documents in one collection differ in fields and data types."}],"answer":"a","explanation":"Documents in one collection can differ in fields and types, and the polymorphic pattern groups them so one query can access them together.","concept":"Documents in one collection can differ in fields and types, and the polymorphic pattern groups them so one query can access them together.","rev":1,"kind":"scenario","takeaways":["Group documents by query access, not by identical shape."]}]