Domain 1: MongoDB Overview and the Document Model
- MongoDB is a document database that stores JSON-like documents; documents live in collections, and collections live in databases.
- Documents are stored as BSON, a binary form of JSON that adds types such as ObjectId, Date, Decimal128, Int32/Int64, Double, Binary, and distinguishes types that JSON cannot.
- Every document has a unique _id; if you do not supply one, MongoDB generates an ObjectId, a 12-byte value that is unique and roughly ordered by creation time.
- MongoDB has a flexible schema: documents in one collection can have different fields, and you can add fields without a migration.
- Documents can nest: embedded documents and arrays let related data live inside one document instead of separate tables.
- Use dot notation ("address.city", "items.0") to reach fields inside embedded documents and array elements.
- A single document has a hard size limit of 16 MB, which is one reason to avoid unbounded arrays.
- mongosh is the shell: `use <db>` selects a database, `db.<collection>` accesses a collection, and `show collections` lists them.
- Field names and string values are case-sensitive, and MongoDB preserves the order of fields and array elements.
- The document model lets data that is accessed together be stored together, which is the foundation for modeling in MongoDB.
Domain 2: CRUD Operations
- Insert with insertOne (returns the insertedId) or insertMany (returns insertedIds); insertMany is ordered by default and stops on the first error unless you pass { ordered: false }.
- Read with find (returns a cursor) and findOne; the filter document uses equality {field: value} plus operators.
- Comparison operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin; logical operators $and (implicit when you list fields), $or, $nor, $not; element operators $exists and $type.
- Query embedded fields with dot notation ("address.city": "NYC"); matching a whole sub-document requires exact field order and contents.
- Query arrays: a plain match finds any element equal to the value; use $elemMatch when multiple conditions must hold on the SAME array element, and $all, $size, or "tags.0" for other array needs.
- Shape results with projection: {field: 1} to include or {field: 0} to exclude - you cannot mix the two except to drop _id with {_id: 0}.
- Order and page results with sort (1 ascending, -1 descending), limit, and skip; large skips are slow.
- Count with countDocuments (accurate, honors a filter) rather than the deprecated count; get unique values with distinct.
- Update with updateOne or updateMany using operators: $set, $unset, $inc, $rename, and $setOnInsert; add upsert: true to insert when nothing matches.
- Update arrays with $push (with $each/$slice/$sort), $addToSet (no duplicates), $pop, and $pull, and target elements with the positional $, all-positional $[], or filtered $[<id>] plus arrayFilters.
- replaceOne swaps the whole document (keeping _id) and its replacement must contain NO update operators; findOneAndUpdate/Replace/Delete return a document and support returnDocument: "after".
- Delete with deleteOne or deleteMany; bulkWrite batches mixed operations; single-document writes are atomic, and multi-document transactions are available when you need all-or-nothing across documents.
Domain 3: Indexes
- Indexes let queries avoid a full collection scan; every collection has a default index on _id.
- Create indexes with createIndex({field: 1}) for ascending or -1 for descending; getIndexes lists them and dropIndex removes them.
- Compound indexes cover multiple fields; order them by the ESR rule - Equality fields first, then Sort fields, then Range fields.
- A compound index supports a query on a prefix of its keys: {a:1, b:1, c:1} serves {a}, {a,b}, and {a,b,c}, but not {b} or {c} alone.
- The same compound index can satisfy both the filter and the sort when the query matches the key order and direction.
- Multikey indexes index array fields (one entry per element); a compound index may include at most one array field.
- Unique indexes enforce uniqueness and raise a DuplicateKey (E11000) error on a repeat value.
- Specialized indexes: text (for $text search, one per collection), 2dsphere (geospatial), TTL (expireAfterSeconds, needs a Date field), partial (partialFilterExpression), sparse, and wildcard.
- A covered query is answered entirely from an index - all queried and returned fields are in the index and _id is projected out - so no documents are read.
- Use explain("executionStats") to see IXSCAN vs COLLSCAN and compare totalKeysExamined, totalDocsExamined, and nReturned to judge whether an index is efficient; hint() forces a specific index.
Domain 4: Data Modeling
- The core principle is that data accessed together should be stored together, so the model follows the application's query patterns.
- Embed related data in one document when it is read together and is bounded - it gives a single read and single-document atomicity.
- Reference (store an ObjectId or key pointing to another document) when data is large, shared, or grows without bound, or when it is queried independently.
- Model relationships by cardinality: one-to-one usually embeds, one-to-many can embed the many side or reference it, and many-to-many typically references.
- Avoid the massive-arrays anti-pattern: unbounded arrays can push a document toward the 16 MB limit and hurt performance, so reference instead.
- Denormalizing (duplicating some data) trades extra storage and update work for faster reads; choose based on the read/write ratio.
- Common patterns at this level include the subset, computed, extended reference, and bucket patterns.
- Because only single-document writes are atomic by default, embedding data that must change together keeps updates atomic.
Domain 5: Aggregation
- An aggregation pipeline is an array of stages; documents flow from one stage to the next, so stage order matters.
- $match filters documents; place it early so it can use indexes and reduce the documents later stages process.
- $project reshapes documents (include, exclude, or compute fields), while $addFields (alias $set) adds or overwrites fields without dropping the rest, and $unset removes fields.
- $group groups by the _id expression and computes accumulators such as $sum, $avg, $min, $max, $push, $addToSet, $first, and $last; _id: null groups all documents into one.
- $sort, $limit, and $skip order and page results within the pipeline.
- $unwind deconstructs an array field into one document per element (preserveNullAndEmptyArrays keeps documents with missing or empty arrays).
- $lookup performs a left outer join to another collection using localField, foreignField, and as, producing an array of matched documents.
- $count and the $group with $sum: 1 pattern both count documents; $out and $merge write the pipeline's results to a collection.
- Inside stages, reference fields with a "$" prefix and use expression operators such as $multiply, $concat, $cond, $switch, $ifNull, $arrayElemAt, and date operators.
- Reading a pipeline top to bottom lets you predict its output, and filtering or projecting early keeps it efficient.
Domain 6: Drivers
- Applications talk to MongoDB through an official driver; the connection string uses mongodb:// or the DNS-based mongodb+srv:// (common with Atlas) and includes hosts, the auth database, and options.
- Common URI options include retryWrites, w (write concern), replicaSet, tls, appName, and maxPoolSize.
- The MongoClient manages a connection pool; create ONE client per application and reuse it rather than opening a client per request.
- From the client you get a database handle and then a collection handle, and driver CRUD methods mirror mongosh: insertOne/insertMany, find, updateOne/updateMany, deleteOne/deleteMany, and aggregate.
- find and aggregate return cursors; iterate them or call toArray, and stream large result sets instead of loading everything into memory at once.
- Drivers map BSON types to native types (ObjectId, Date, Decimal128) so your code works with real objects, not raw JSON.
- Handle errors: catch write errors, DuplicateKey (code 11000), and timeouts; retryable writes automatically retry certain transient failures.
- Read preference (primary, secondaryPreferred, and others) and write concern can be set in the URI or per operation.
- Do not hardcode credentials - supply the connection string from configuration or environment variables - and consider the Stable API for version compatibility.
MongoDB Associate Developer exam tips
- Weight your prep heavily toward CRUD - it is 51% of the exam. Be fluent with find and the query operators ($in, $elemMatch, dot notation on arrays and embedded documents), updates ($set vs replacement, $push vs $addToSet, positional $ vs $[] vs $[<id>]), upsert, projection rules, and sort/limit/skip.
- Know the array gotchas cold: $elemMatch applies multiple conditions to the SAME array element, whereas multiple dot-notation conditions can match across different elements; and matching a whole embedded document requires exact field order while dot notation matches a single field.
- For indexes, memorize the ESR rule (Equality, Sort, Range) and the compound-index prefix rule, then practice reading explain("executionStats") - IXSCAN vs COLLSCAN and the keys-examined vs docs-returned ratio - and recognize a covered query.
- For aggregation, learn the common stages ($match, $group with accumulators, $project/$addFields, $sort, $unwind, $lookup) and remember to put $match and $project early; be able to trace a pipeline and predict its output.
- For drivers, the two most-tested ideas are the connection string (mongodb+srv, options like retryWrites and maxPoolSize) and connection pooling - reuse a single client. Distinguish deprecated helpers (insert, update, remove, count) from the current methods.
Study guide FAQ
What is the format of the MongoDB Associate Developer exam?
It is 53 questions - multiple choice and multiple response - to be answered in 90 minutes, delivered online-proctored. It is language-agnostic: questions use mongosh and the MongoDB Query Language rather than a single driver language. MongoDB does not publish a fixed passing percentage.
Do I need to know a specific programming language?
No. The Associate Developer exam is language-agnostic and focuses on MongoDB concepts, mongosh, and MQL. You should understand how drivers work in general (connection strings, pooling, CRUD methods, cursors), but you are not tested on one language's syntax.
How much of the exam is CRUD?
About 51%, more than half. The rest is Indexes (17%), Aggregation (11%), Drivers (9%), the Document Model (8%), and Data Modeling (4%). Prioritize CRUD depth - queries, updates, and their operators - while still covering indexes and aggregation well.
What is the difference between the Associate Developer and the Associate DBA?
The Associate Developer focuses on building applications - CRUD, the document model, indexing for queries, aggregation, and drivers. The Associate DBA focuses on operating MongoDB - deployment, replica sets, sharding, backup, security, and monitoring. They are separate credentials.
Is CertGrid's practice official MongoDB material?
No. CertGrid is an independent practice platform and is not affiliated with or endorsed by MongoDB. These questions are original and written to mirror the current exam guide's sections and mongosh/MQL style so you can rehearse the objectives. Always confirm the current exam guide on the official MongoDB University page before your exam.