Study guide · Core notes

MongoDB Associate Developer core notes

Reference notes for the current Associate Developer exam. Each section names the object, and what you check in a database you are allowed to drop.

Reviewed November 19, 2026Six sectionsCRUD includes aggregation and Atlas Search

How to read these notes: Unmarked items sit on the public Associate Developer objectives or the MongoDB docs they point at. Items tagged Extra are job context that outline does not require. New to the exam? Start with the overview. Practice in a cluster or local database you can remove.

MongoDB Overview and the Document Model

8 percent. Documents, BSON, collections, and when to embed.

Documents and _id

A document is the primary unit of storage. Drivers expose JSON-like objects. Storage and the wire protocol use BSON, which adds typed values such as ObjectId and Date. Every document needs a unique _id in its collection. Most drivers generate an ObjectId when you omit _id; the server can generate one if the driver does not.

Databases and collections

A database holds collections. A collection holds documents. Indexes belong to a collection. The shell and drivers address data as database then collection. Collections do not require every document to share the same fields unless you add schema validation.

Embedding versus referencing

Embed data that is read and written together and stays within size limits. Reference when entities grow large, update independently, or are reused under many parents. The BSON document size limit is 16 MB.

Flexible schema

Different documents in one collection can carry different fields and nested shapes. That flexibility is intentional. Validation rules are optional. Extra Relational foreign keys are not how MongoDB enforces related documents by default.

CRUD

51 percent. Writes, reads, aggregation, and Atlas Search.

Inserts and replaces

insertOne adds one document. insertMany adds many. replaceOne swaps a document body while keeping _id. Duplicate _id values raise duplicate key errors when uniqueness collides.

Updates and upserts

$set assigns fields. $unset removes them. $inc changes numbers. $push, $pull, and $pop change arrays. $setOnInsert applies only when an upsert inserts. Without upsert, a miss updates zero documents. updateMany updates every match. findOneAndUpdate can return the pre-image or post-image depending on driver options.

Queries, projection, cursors, counts

Equality, $gt, $gte, $lt, $lte, $in, $or, $all, $elemMatch, $size, and $exists are common filters. Dot notation reaches nested fields. Projection shapes returned fields; it does not change the match. find returns a cursor. limit, sort, and hint control the cursor. countDocuments filters. estimatedDocumentCount uses metadata.

Aggregation and Atlas Search

$match filters. $group aggregates. $project reshapes. $lookup joins another collection. $out replaces a target collection with pipeline results. $merge can incorporate into existing data. Atlas Search uses a search index and $search for relevance queries. Put selective $match early when indexes can help.

Worked write: upsert then summarize

Make email unique before using it as an upsert key, then update a customer profile and materialize totals:

db.customers.createIndex({ email: 1 }, { unique: true })

db.customers.updateOne({ email: "ada@example.com" }, { $set: { plan: "pro" }, $setOnInsert: { createdAt: new Date() } }, { upsert: true })

db.orders.aggregate([{ $group: { _id: "$customerId", total: { $sum: "$amount" } } }, { $out: "customer_totals" }])

Without upsert, the update changes nothing on a miss. Concurrent upserts can create duplicates when the filter is not uniquely indexed. $out replaces customer_totals with the grouped result; use $merge when existing unrelated target documents must remain.

Indexes

17 percent. createIndex, compound order, and explain.

Single-field and unique

createIndex({ email: 1 }) builds an ascending index. Use -1 for descending. unique rejects duplicate keys. Indexes speed selective filters and can slow writes because each write updates the index.

Compound and ESR

A compound index orders multiple fields. A common heuristic is equality fields first, then sort fields, then range fields. Prefix rules decide which query shapes an index can support.

Special index types

Text indexes support $text. TTL indexes expire documents from a date field through a background process, so deletion is not immediate. Partial indexes cover a filter subset. Multikey indexes appear when an indexed field is an array. Hashed indexes support hashed equality patterns. Atlas Search indexes are separate from ordinary createIndex trees.

explain and covered queries

explain shows whether a plan uses an index or a collection scan. A covered query answers from the index alone without fetching full documents. listIndexes describes defined indexes. Extra Always measure with your real filter selectivity; an unused index is pure write cost.

Data Modeling

4 percent. Access patterns, duplication, and array growth.

Design for reads and writes

Model from the queries you run. Embed co-accessed data. Reference independent lifecycles. Controlled duplication of stable labels can simplify read-heavy pages.

Subset and unbounded arrays

The subset pattern keeps a small hot slice with the parent and stores full detail elsewhere. Unbounded arrays inflate documents, slow rewrites, and approach the BSON size limit. Bucket or reference when lists grow without bound.

Tools and Tooling

2 percent. Atlas sample data and Data Explorer.

Data Explorer

Atlas Data Explorer browses databases, collections, and documents in the UI without writing an application. Use it to inspect shapes before you automate the same find in a driver.

Sample datasets

Atlas sample datasets such as sample_mflix give ready collections for practice queries and aggregations. They do not award credentials and they do not replace indexes on your own data.

Drivers

18 percent. URI, pooling, and language APIs.

URI and client

A connection URI names protocol, hosts, optional credentials, and a default database. Atlas commonly uses mongodb+srv. MongoClient is the process entry point. Prefer one shared client so the pool is reused.

CRUD in drivers

PyMongo uses insert_one, update_one, find, and aggregate with a list of stages. The Node driver uses insertOne, updateOne, find (cursor), and aggregate with promises or async/await. findOne returns null or None on a miss by default.

Pooling and write concern

Pools reuse TCP connections. Configure pool size on the client or URI options. Write concern can be set on the client, database, collection, or operation depending on the driver. Abandoned cursors pressure server resources.

Language track note

At registration you choose Node.js, Python, Java, PHP, or C#. Practice banks here often show PyMongo or mongosh-style examples; the ideas map across official drivers. Extra Do not commit plaintext URI credentials to a public repository.

Worked cases: model the invariant before choosing an operation

Use a disposable database for these original examples. For each write, define what must remain true if two requests arrive at once, if a client retries, or if the application loses the response. A successful command is only one part of a correct workflow.

Reserve inventory with a conditional update

A product document has a remaining quantity. Reading that quantity in the application and later writing a calculated replacement can lose concurrent changes. A single-document conditional update can express the availability check and decrement together:

db.inventory.updateOne(
  { _id: 'LAB-1', available: { $gte: 2 } },
  { $inc: { available: -2 } }
);

Inspect the matched count. Zero means that no document satisfied the filter; it must not be reported as a successful reservation. Atomicity applies to this single-document operation. Creating a separate order document and charging an external payment service are additional steps with their own failure cases. Consider an appropriate transaction for database changes that must be atomic together, while handling external effects through an explicit, retry-aware workflow.

Choose embedding by access pattern and growth

An order can embed a bounded set of line items that are normally read together. Storing every lifetime order inside one customer document creates an unbounded array and increasing write contention. Referencing separate orders supports independent growth and access. The right choice depends on read and write patterns, size, update frequency, and the invariants that need atomicity; “document database” does not mean every related record belongs in one document.

Distinguish a historical snapshot from a live reference. An order's agreed unit price may intentionally remain unchanged when the product catalog price changes. Copying that value is not automatically a synchronization defect. By contrast, duplicating a customer's current contact preference across many documents requires a clear update strategy. Write down which copied values are historical facts and which must track a current source.

Test array predicates with a counterexample

Imagine an array containing one item with color red and size small, and another with color blue and size large. Separate dotted-field conditions for red and large may match different array elements. If the requirement is one item that is both red and large, use an appropriate $elemMatch predicate. Test a document with the two conditions split across elements and another where one element satisfies both. This reveals the difference more clearly than memorizing the operator name.

Evaluate an index with representative data

A query filters by customer identifier and sorts orders by creation time. A compound index beginning with that equality field and followed by the sort field may support the access pattern. Field order matters; the same fields in a different order do not guarantee the same benefit. Inspect explain output, keys and documents examined, and whether an extra sort remains. Test enough varied data to avoid drawing conclusions from a tiny collection.

Indexes consume space and add write work. A unique index enforces a data rule, while a nonunique index primarily supports access. Neither validates all business requirements. Before adding a unique index to existing data, identify duplicates and agree how to resolve them. Before removing an index, check the wider workload rather than only one query.

Make retry behavior part of application design

Use a stable business request identifier when the same request could arrive twice. Enforce its intended uniqueness and decide how to return an existing result. A network timeout does not by itself prove that a write failed; the server may have completed work before the response was lost. Driver retryable writes address supported cases, but they do not automatically make an arbitrary multi-step workflow or external notification idempotent.

Technical references: MongoDB atomicity and transactions and compound indexes.

Eight checks on a disposable database

Say what you expect to see before you change the data. Then drop the database if it was only for practice.

A document that must get an _id

insertOne a document without _id, then find it and read the generated ObjectId.

What to verify: MongoDB created _id. A second insert with the same explicit _id fails with a duplicate key error.

An upsert that must insert on miss

updateOne with upsert false on a missing filter, then the same update with upsert true.

What to verify: the first call matches zero. The second inserts. $setOnInsert fields appear only on the insert path.

An index plan to compare

Load enough varied documents for a selective filter, run explain("executionStats"), createIndex on the filter field, and run explain again. Inspect the winning plan and documents examined.

What to verify: an IXSCAN may replace COLLSCAN and reduce examined documents. The planner is allowed to keep a collection scan for a small or unselective dataset; creating an index alone does not force its use.

A model that must stop growing an array

Embed a comments array, grow it, then move new comments to a referenced collection.

What to verify: the parent document stops ballooning while related reads still work with a follow-up query or $lookup.

A sample dataset browse

Open or load an Atlas sample dataset and inspect a collection in Data Explorer.

What to verify: you can see document fields in the UI, then run the same find in mongosh or a driver.

A driver client that must be shared

Create one MongoClient from a URI, run several finds and one aggregate, and avoid constructing a new client per operation.

What to verify: operations succeed on the shared client. Pool settings live on the client, not inside a $match stage.

One array element or two

Insert one document with scores [70, 90] and another with [82]. Compare a range query on scores using $gt: 80 and $lt: 85 with the same conditions inside $elemMatch.

What to verify: separate array elements can satisfy the ordinary range query; only the document containing 82 satisfies both conditions on one element with $elemMatch.

Replacing versus merging a summary

Seed a target collection with a marker document. Run an aggregation ending in $out to that target, then repeat with a fresh target and $merge.

What to verify: $out replaces the target collection after the pipeline succeeds. $merge incorporates matching or new result documents and leaves an unrelated marker in place by default.

Frequently asked questions

Which exam do these notes follow?

These notes follow MongoDB Certified Associate Developer and the current six-section study-guide structure. Aggregation and Atlas Search sit inside CRUD. Old C100DEV replication and sharding domains are not this outline.

Does upsert insert when nothing matches?

Yes, when upsert is true. Without upsert, a non-matching update changes zero documents. $setOnInsert applies only when an upsert inserts.

What does $out do in aggregation?

$out writes the pipeline result to a collection, replacing that collection’s contents. $merge can incorporate results into an existing collection with richer modes.

Should an app create a MongoClient per request?

No. Create one MongoClient for the process so the connection pool is shared. Opening a client per request wastes sockets and monitoring work.

Continue the MongoDB study path

The overview, core notes, flashcards, and practice exams are all published.

MongoDB hub →
Available

Overview

Exam format, the six section weights, and a lab plan.

Available · You are here

Core Notes

Reference notes for CRUD, indexes, modeling, and drivers.

Available

Practice Exams

200 original questions across the six official sections.

Official exam sources

Notes follow the MongoDB Associate Developer exam page and developer learning paths. Operator behavior is in the CRUD documentation and index documentation.

AWS Data Engineer

An AWS data pipeline exam. It is not the MongoDB Associate Developer credential.

CompTIA Data+

A vendor-neutral data exam. It does not award a MongoDB certification.

Apply concepts in the Scenario Workshop →