Document modelling, the aggregation pipeline, indexes, transactions and replication.
A hardware store's invoice screen shows the value of each line.
invoice_lines documents are { _id, sku, unitPrice, qty }. Return one
document per line shaped { _id, sku, lineTotal }, where lineTotal is
unitPrice multiplied by qty (a line with no qty gets
A language school awards a certificate when a student's average quiz
score is at least 70. students documents are { _id, name, quizzes: [number] }.
Return the students who qualify as { _id, name, avg }, where avg is the
average of their quizzes. Students with no quizzes (empty or missing
A bakery chain records each sale in sales as { _id, category, amount }
(category is "bread", "cake", and so on). Return the total sales amount
per category, one document per category, shaped { _id: <category>, total }.
Order does not matter.
A courier tracks parcels in deliveries as { _id, status }. Build the
status breakdown for the operations screen: one document per status,
{ _id: <status>, count }, ordered by count from highest to lowest; when
two statuses have the same count, order them by _id ascending.
A book review site only shows an average once a book has enough reviews.
reviews documents are { _id, bookId, stars }. For every book with
at least 2 reviews, return { _id: <bookId>, avgStars, reviews }, where
reviews is the number of reviews. Order does not matter.
In a $group stage, what is the difference between { $sum: 1 } and
{ $sum: "$quantity" }? What does $sum do with a document where
quantity is missing?