Home / MongoDB Associate Developer / Mock exam
MongoDB Associate Developer Exam-style mock test

MongoDB Associate Developer Practice Exams|Practice test

Full explanations Exam format Pass line 70%
33 USD One-time · lifetime access
Enroll →

Sample questions

Example1 · Documents & Data Modeling
At a B2B SaaS company, each customer account owns a small, bounded list of billing contacts that is almost always read together with the account and rarely changes on its own. Which data model best fits this one-to-few relationship that is read as a unit?
・Store each billing contact in a separate collection and join them to the account at query time using a $lookup aggregation stage on every read
Incorrect. A $lookup join on every read adds overhead and is unnecessary for a small, bounded set that is always read with its parent account.
✓Embed the billing contacts as an array of subdocuments directly inside the parent account document so they load together
Correct. For a one-to-few relationship that is read as a unit and changes infrequently, embedding the contacts as an array of subdocuments gives a single-read model.
・Keep contacts in their own collection and duplicate the full account document inside each contact for fast single reads
Incorrect. Duplicating the full account inside each contact creates redundant data that must be kept consistent and does not match a one-to-few read-as-a-unit pattern.
・Create a third bridging collection that pairs account identifiers with contact identifiers for many-to-many lookups
Incorrect. A bridging collection models many-to-many relationships, but billing contacts here belong to exactly one account in a one-to-few shape.
Explanation
One-to-few relationships that are read together and rarely updated independently are best embedded as an array of subdocuments, avoiding joins and giving single-document reads.
Example2 · CRUD Operations
A developer at a B2B SaaS billing platform runs insertOne() to add a new tenant document that does not include an _id field. The application needs the identifier of the inserted document to log it. Where can the developer obtain the identifier that MongoDB assigned to this document?
✓From the insertedId property returned on the result object produced by the insertOne() call
Correct. When no _id is supplied, MongoDB generates an ObjectId and returns it on the result object as insertedId.
・By issuing a separate findOne() with the full tenant payload to locate the created record afterward
Incorrect. A follow-up query is unnecessary and unreliable, since insertOne() already returns the generated identifier directly.
・From the acknowledged boolean flag that insertOne() returns once the server confirms the write
Incorrect. The acknowledged flag reports only whether the write was acknowledged, not the value of the generated _id.
・Only by explicitly supplying an _id yourself, because MongoDB does not generate one on insert
Incorrect. MongoDB automatically generates an ObjectId _id when none is provided, so supplying one manually is not required.
Explanation
insertOne() returns a result document whose insertedId field holds the _id of the new document, auto-generated as an ObjectId when omitted.
Example3 · Indexes & Performance
At the B2B SaaS firm TeamFlow, the dashboard runs db.accounts.find({ tenantId: "acme" }) thousands of times per minute and it currently performs a full collection scan. A developer wants the single most direct index to serve this exact equality lookup. Which command should the developer run?
✓db.accounts.createIndex({ tenantId: 1 })
Correct. A single-field ascending index on tenantId directly supports the equality predicate and lets the query use an index scan instead of a collection scan.
・db.accounts.createIndex({ tenantId: "text" })
Incorrect. A text index tokenizes string content for $text searches and cannot serve a simple equality match on tenantId efficiently.
・db.accounts.createIndex({ tenantId: 1, createdAt: 1, status: 1 })
Incorrect. This compound index works but adds two unused fields; the task asked for the single most direct index for the equality lookup, not a broader compound index.
・db.accounts.createIndex({ tenantId: 1 }, { unique: true, sparse: true })
Incorrect. Adding unique and sparse options changes data constraints and would reject duplicate tenantId values, which is wrong since many accounts share a tenant.
Explanation
A single-field ascending index on the queried field is the most direct way to turn a collection scan into an index scan for an equality predicate.
Example4 · Aggregation Framework
At a healthcare services firm, an analyst runs a pipeline on the 'claims' collection to total approved claim amounts per clinic. The pipeline has both a $match on status 'approved' and a $group by clinicId. To make the aggregation most efficient, where should the $match stage be placed relative to the $group stage?
・Place $match after $group so the grouped totals can be filtered down to approved clinics in a single consolidated pass over the data
Incorrect. Filtering after $group means every document is grouped first, so the early document reduction and index usage are both lost.
✓Place $match before $group so it reduces the documents early and can leverage an index on the status field
Correct. A $match placed before $group reduces the input set early and can use an index on status, which is the optimal ordering here.
・Place $match inside the $group stage using an embedded condition expression so both run together efficiently
Incorrect. $group does not accept an embedded $match condition; filtering must be its own stage placed earlier in the pipeline.
・Place $match last in the pipeline because filtering always runs most efficiently as the final step
Incorrect. Placing $match last forces the pipeline to process all documents through $group first, defeating early filtering entirely.
Explanation
Positioning $match before $group lets MongoDB shrink the working set early and use indexes, which is the key optimization pattern.
Example5 · Drivers, Transactions & Tools
A healthcare services firm is building a new patient-intake microservice in Node.js that must read and write documents in their MongoDB Atlas cluster. The backend team asks which component they should add to the service so the application code can issue CRUD operations against the deployment. What should they use?
✓The official MongoDB Node.js driver, which exposes a client API that connects to the cluster and runs database commands
Correct. Official drivers are language-specific libraries (here, the Node.js driver) that provide the client API used to connect and run CRUD operations from application code.
・The mongosh shell binary, which they can embed and invoke from the service to run interactive queries against the cluster
Incorrect. mongosh is an interactive administrative/query shell, not a library meant to be embedded inside an application service for routine CRUD.
・The mongoimport command-line tool, which they should call from the service whenever a patient document needs to be written
Incorrect. mongoimport is a one-off bulk-loading utility for files, not the mechanism an application uses to perform ongoing CRUD operations.
・A manually crafted BSON-over-TCP socket layer that speaks the MongoDB wire protocol directly without any supporting library
Incorrect. Hand-writing the wire protocol is impractical and unnecessary because the official driver already implements it reliably.
Explanation
Applications talk to MongoDB through the official language driver, which implements the wire protocol and exposes a CRUD client API. mongosh, mongoimport, and raw sockets are not the right tool for application-level data access.
Example6 · Documents & Data Modeling
A healthcare services firm stores each patient and their visit history. Visits are almost always read together with the patient record, there are at most a few dozen per patient, and a visit is never queried on its own. Which data model best fits this access pattern?
✓Embed the visits as an array of subdocuments inside each patient document so the whole record loads in one read
Correct. Because visits are bounded, always read with the patient, and never queried alone, embedding them keeps the data together and serves it in a single read.
・Store each visit in a separate visits collection and link it back using a patient_id reference field
Incorrect. Referencing adds a second query or join for data that is always read together and is small and bounded, so it adds overhead without benefit.
・Create a separate visits collection and resolve the patient link at query time with a $lookup aggregation stage
Incorrect. A $lookup join on every read is unnecessary cost for a bounded set that is only ever accessed as part of the patient record.
・Keep visits in their own collection and periodically copy a summary of them back into the patient document
Incorrect. Maintaining duplicated summaries adds write complexity and consistency risk that this simple bounded one-to-few relationship does not require.
Explanation
A bounded one-to-few relationship that is always accessed together is the classic case for embedding, giving single-read access without join overhead.
Example7 · Documents & Data Modeling
The engineering team at UrbanThread, an online apparel retailer, stores each customer order with a short list of line items that are always read together with the order and never queried on their own. They want the fewest round trips when displaying an order. Which data model best fits this access pattern?
✓Store the line items as an embedded array inside the order document itself
Correct. Because the line items are always read with the order and never alone, embedding them as an array keeps everything in one document and one read.
・Keep each line item in a separate collection and join it to the order at read time with $lookup
Incorrect. A separate collection joined with $lookup adds overhead for data that is always accessed together as a unit.
・Create one document per line item that carries a copy of every order-level header field alongside it
Incorrect. Duplicating every order header field onto each line item wastes space and complicates updates without improving the single-order read.
・Split line items into a sibling collection and manually fetch them with a second query keyed by order id
Incorrect. A second keyed query forces an extra round trip for data that could have been embedded and returned at once.
Explanation
Data that is accessed together and bounded in size is a classic candidate for embedding, which satisfies reads with a single document fetch.
Example8 · Documents & Data Modeling
At UrbanThread, each product can accumulate tens of thousands of customer reviews over its lifetime, and reviews are usually browsed on a dedicated paginated screen, not with the product details. How should the reviews be modeled?
・Embed every review in an array on the product document so they travel with the product
Incorrect. Embedding tens of thousands of reviews risks hitting the document size limit and bloats every product read.
✓Store reviews in their own collection, each referencing the product by its _id
Correct. An unbounded, independently browsed set belongs in its own collection with a reference back to the product by _id.
・Place the reviews in a nested array but periodically trim it down to the newest entries only
Incorrect. Trimming an embedded array loses reviews and still couples review growth to the product document.
・Keep a review array on the product and also mirror each review into a second summary collection
Incorrect. Maintaining both an embedded array and a mirror collection duplicates data and creates synchronization burden.
Explanation
When the related set grows without bound and is queried separately, referencing avoids the document size limit and keeps the parent document lean.
Example9 · Documents & Data Modeling
A developer at UrbanThread must store the exact moment each order was placed so it can be sorted and range-queried by date. Which BSON type should the order's placement field use?
・A plain string formatted as an ISO-8601 calendar timestamp for readability
Incorrect. A string sorts lexically and is not a true temporal type, making range queries fragile.
✓The BSON Date type, which stores the instant as a 64-bit value
Correct. The BSON Date type stores the instant as a 64-bit integer and supports proper sorting and range queries.
・An embedded document holding separate year, month, day, and hour integer fields
Incorrect. Splitting a timestamp into separate integer fields complicates comparisons and range filters.
・A 32-bit integer counting whole seconds elapsed since the Unix epoch
Incorrect. A 32-bit epoch integer loses sub-second precision and risks overflow, and it is not the native date type.
Explanation
BSON Date is the native type for points in time and enables correct chronological sorting and range queries.
Example10 · Documents & Data Modeling
A payments team at a financial services firm stores each customer and a short list of their saved payees that is always displayed together on the transfer screen. The payee list is small, rarely changes, and is never queried on its own. Which data modeling approach best fits this access pattern?
✓Store the saved payees as an embedded array inside the customer document so they load in a single read
Correct. Because the small payee list is bounded, changes rarely, and is always read with the customer, embedding it as an array lets the whole screen load in one read with no join.
・Create a separate payees collection and join it to customers at query time using an aggregation lookup every time
Incorrect. A separate collection joined via $lookup on every read adds overhead that the always-together, small, stable payee list does not justify.
・Keep payees in their own collection and duplicate the full customer record into each payee document for speed
Incorrect. Duplicating the full customer record into every payee document wastes storage and creates update anomalies without improving this read pattern.
・Store each payee as its own top-level document referencing the customer by an application-managed foreign key
Incorrect. Separate referenced documents force extra lookups for data that is bounded and always accessed alongside the customer.
Explanation
Data that is small, bounded, stable, and always accessed together is a classic case for embedding, which serves the whole view in a single read.
Example11 · Documents & Data Modeling
A bank account at the firm can accumulate millions of transactions over its lifetime, and transactions are frequently queried on their own for statements and audits. A developer is deciding how to model the account-to-transaction relationship. Which approach is most appropriate?
・Embed every transaction in an array within the account document to keep all data in one place
Incorrect. Embedding millions of transactions risks exceeding the 16 MB document limit and bloats every account read.
✓Store transactions in a separate collection, each referencing its account by id
Correct. An unbounded, independently queried relationship should use referencing, keeping transactions in their own collection linked by account id.
・Embed the most recent transactions and periodically copy the older ones into a backup collection
Incorrect. Splitting recent versus backup embeds still grows the account document and complicates statement queries that span all history.
・Store transactions in a separate collection and additionally embed the complete transaction array into the account document for convenience
Incorrect. Keeping a separate collection while also embedding the full array reintroduces the unbounded-growth problem and duplicates data.
Explanation
One-to-many relationships that are unbounded and queried independently are modeled with referencing so documents stay within limits and remain performant.
Example12 · Documents & Data Modeling
A manufacturing distributor stores each part's weight in kilograms, including fractional values like 2.75, in the parts collection. Which BSON type should the developer use so arithmetic in aggregation stages behaves naturally for these fractional measurements?
・The string type, storing the number as text so that the exact characters entered by the operator are preserved during import
Incorrect. Storing numbers as strings blocks numeric operators and comparisons, forcing conversion before any aggregation math can run.
✓The double type, which stores the fractional weight as a floating-point number suitable for aggregation arithmetic
Correct. The double type represents fractional values such as 2.75 and participates directly in aggregation arithmetic.
・The ObjectId type, which generates a unique twelve-byte identifier that can also encode the measurement timestamp
Incorrect. ObjectId is an identifier type for unique document keys, not a numeric type for storing measured weights.
・The 32-bit integer type, which stores whole numbers only and truncates any fractional component during insertion
Incorrect. A 32-bit integer holds whole numbers only, so fractional weights like 2.75 cannot be represented accurately.
Explanation
Fractional numeric measurements map to the double (floating-point) BSON type, which supports aggregation arithmetic directly.
Example13 · Documents & Data Modeling
A developer inserts a supplier document into the distributor's suppliers collection without specifying an _id field. What does MongoDB do with the _id for that newly inserted document?
・MongoDB rejects the insert operation and returns a validation error because every document must supply its own explicit _id value
Incorrect. MongoDB does not reject inserts missing an _id; it supplies one on the client or server side automatically.
✓MongoDB automatically generates a unique ObjectId and assigns it to the _id field of the new supplier document
Correct. When _id is omitted, MongoDB generates a unique ObjectId and assigns it as the document's primary key.
・MongoDB leaves the _id field absent until the first update operation on the document later populates it with a value
Incorrect. The _id is assigned at insert time, not deferred until a later update touches the document.
・MongoDB copies the value of the first indexed field in the document and reuses it as the document's _id value
Incorrect. MongoDB does not derive _id from another indexed field; it creates a new ObjectId when none is given.
Explanation
Every document requires an _id; when omitted, MongoDB auto-generates a unique ObjectId as the primary key.
Example14 · Documents & Data Modeling
A telecom operator stores each subscriber with a short list of phone numbers that is almost always read together with the subscriber and rarely changes. Which document design best fits this access pattern?
✓Embed the phone numbers as an array field inside each subscriber document so they load in a single read
Correct. Because the numbers are read with the subscriber and seldom change, embedding them as an array keeps the data in one document and avoids extra reads.
・Create a separate phoneNumbers collection and join it to subscribers at query time using $lookup
Incorrect. A separate collection joined with $lookup adds query cost and complexity that is unnecessary for data always read together.
・Store each phone number as its own document that holds a copy of the full subscriber profile fields
Incorrect. Duplicating the full subscriber profile into each phone-number document creates heavy redundancy and update anomalies.
・Keep phone numbers in a parallel collection referenced by a subscriberId field and query it separately
Incorrect. A referenced parallel collection forces a second query for data that is almost always accessed alongside the subscriber.
Explanation
Data that is accessed together and changes rarely is a classic candidate for embedding, which satisfies reads in a single operation.
Example15 · Documents & Data Modeling
A telecom operator records call detail records (CDRs) for each subscriber, and a single subscriber can accumulate millions of CDRs over time. How should the CDRs be modeled relative to the subscriber document?
・Embed every CDR in an array inside the subscriber document to keep all activity together
Incorrect. Embedding millions of CDRs risks exceeding the 16 MB document limit and causes unbounded array growth.
✓Reference the subscriber from each CDR document stored in a dedicated CDR collection by subscriberId
Correct. A separate CDR collection referencing the subscriber by subscriberId handles the one-to-millions, unbounded relationship cleanly.
・Store the most recent CDR embedded and discard any older records from the database entirely
Incorrect. Keeping only the newest CDR discards data the operator needs and does not model the relationship.
・Place all CDRs for all subscribers inside one shared array in a single global metrics document
Incorrect. One global array for all subscribers would grow without bound and create severe contention on a single document.
Explanation
Unbounded one-to-many relationships should be referenced in their own collection rather than embedded to avoid the document size limit and array growth problems.
▶ Try 10 free questions (graded)
Measure your readiness with a full mock exam
All questions · full explanations · lifetime access
Enroll(33 USD)