MongoDB Certified Associate Developer

Question bank

MongoDB logo

MongoDB Certified Associate Developer

MongoDB-DEV

40 MongoDB Certified Associate Developer questions with the correct answer and a written explanation, organised across 6 exam domains.

40 questions
6 domains
Foundation level

Question index

Jump straight to any question. Answers and explanations are inline.

Aggregations

8 questions in this domain

  1. Question 1Single Choice

    What data structure does MongoDB use for single field indexes?

    • AB-TreeCorrect answer
    • BHash table
    • CLinked list
    • DBinary heap

    Why this is the answer

    MongoDB uses a B-Tree for single field indexes, enabling efficient logarithmic searches and sorted operations.

  2. Question 2Multiple Select

    Which statements about single field index direction are correct? Select all that apply.

    • ADirection is irrelevant for equality matches.Correct answer
    • BDirection is important when the index supports a sort.Correct answer
    • CA single field index can only be traversed in one direction.
    • DDescending indexes cannot support equality queries.

    Why this is the answer

    For equality matches index direction does not matter, but for sort operations direction determines whether MongoDB can traverse the index in the required order.

  3. Question 3Interactive

    Given the code snippet that creates an index on a field containing an array, what type of index will be created?

    • AMultikey indexCorrect answer
    • BSparse index
    • CCompound index
    • DWildcard index

    Why this is the answer

    Indexing an array field causes MongoDB to create a multikey index with an entry for every array element.

  4. Question 4Single Choice

    What is true about a sparse index?

    • ADocuments that have the indexed fieldCorrect answer
    • BAll documents in the collection
    • COnly documents with array fields
    • DOnly documents created recently

    Why this is the answer

    Sparse indexes contain entries only for documents that possess the indexed field, reducing index size and memory use.

  5. Question 5Multiple Select

    Which operations are slowed down by adding too many indexes to a collection? Select all that apply.

    • AInsert operationsCorrect answer
    • BUpdate operationsCorrect answer
    • CDelete operationsCorrect answer
    • DRead operations

    Why this is the answer

    Every index must be updated on insert, update, and delete; write-heavy workloads suffer most from excessive indexing.

  6. Question 6Interactive

    The code snippet creates a compound index on three fields. Which query can use this index based on the prefix rule?

    • AA query filtering only on the first fieldCorrect answer
    • BA query filtering only on the second field
    • CA query filtering only on the third field
    • DA query filtering only on the second and third fields

    Why this is the answer

    A compound index supports queries on prefixes of its fields, such as the first field alone, but not non-prefix combinations.

  7. Question 7Single Choice

    In this scenario, according to the ESR rule, what is the recommended order of fields in a compound index?

    • AEquality, Sort, RangeCorrect answer
    • BRange, Sort, Equality
    • CSort, Range, Equality
    • DEquality, Range, Sort

    Why this is the answer

    The ESR rule places equality fields first, then sort fields, and finally range fields for maximum index efficiency.

  8. Question 8Multiple Select

    What statements about multikey indexes are correct? Select all that apply.

    • AAn index on an array creates an entry for each array element.Correct answer
    • BA compound index cannot include more than one array field.Correct answer
    • CA compound multikey index can include two array fields.
    • DMultikey indexes and wildcard indexes serve the same purpose.

    Why this is the answer

    Multikey indexes create entries for each array element, and a compound index is limited to at most one array field to avoid a Cartesian product.

CRUD Operations

8 questions in this domain

  1. Question 9Single Choice

    In MongoDB, what data structure is used to implement single-field indexes for efficient lookups and sorting?

    • AB-TreeCorrect answer
    • BHash table
    • CLinked list
    • DBinary heap

    Why this is the answer

    MongoDB uses a B-Tree, which enables logarithmic time complexity for lookups, range queries, and sorting.

  2. Question 10Multiple Select

    When evaluating a single-field index in MongoDB, which two statements accurately describe the role of ascending and descending direction?

    • AIrrelevant for equality matchesCorrect answer
    • BCritical for supported sort operationsCorrect answer
    • CDetermines number of index entries
    • DDescending indexes cannot help sorting

    Why this is the answer

    For equality matches, a single-field index can be traversed both ways. For sorts, direction must match the requested order.

  3. Question 11Interactive

    Review the query in the code block. According to the ESR rule, which compound index field order is optimal?

    • Astatus, created_at, totalCorrect answer
    • Bcreated_at, status, total
    • Ctotal, status, created_at
    • Dstatus, total, created_at

    Why this is the answer

    ESR says equality fields first, then sort fields, then range fields. Thus status, created_at, and total is optimal.

  4. Question 12Single Choice

    Why is an index on a high-selectivity field such as user_id more efficient than one on a low-cardinality field such as gender?

    • ADiscards more non-matching documentsCorrect answer
    • BReduces need for multikey indexes
    • CPrevents all write overhead
    • DGuarantees sort without indexes

    Why this is the answer

    High selectivity means many unique values, so the index can discard more non-matching documents and narrow the result set quickly.

  5. Question 13Multiple Select

    Select the two correct statements about how MongoDB handles an index on a field that contains an array.

    • AAutomatically created for array fieldsCorrect answer
    • BOne entry per array elementCorrect answer
    • CCompresses array entries into one
    • DCannot contain array fields

    Why this is the answer

    When the indexed field is an array, MongoDB automatically creates a multikey index with one entry for each array element.

  6. Question 14Interactive

    Given the index creation in the code block, what type of index will MongoDB build if the tags field contains arrays?

    • AMultikey indexCorrect answer
    • BSparse index
    • CPartial index
    • DCompound index

    Why this is the answer

    Indexing an array creates a multikey index, with entries per array element for efficient element lookups.

  7. Question 15Single Choice

    In a MongoDB collection, which documents are included in a sparse index built on a particular field?

    • APossess the indexed fieldCorrect answer
    • BFail the index filter
    • CHave high cardinality values
    • DWere updated recently

    Why this is the answer

    A sparse index contains entries only for documents that actually have the indexed field, reducing index size and memory.

  8. Question 16Multiple Select

    Select the two true statements about how adding indexes affects insert, update, and delete operations in MongoDB.

    • AAdds overhead to every writeCorrect answer
    • BSlows write-heavy workloadsCorrect answer
    • CAlways reduces write latency
    • DSkipped during updates

    Why this is the answer

    Each index B-tree must be updated on writes, so adding indexes can slow down insert, update, and delete operations.

Data Access (Driver usage)

6 questions in this domain

  1. Question 17Single Choice

    Which underlying data structure powers single field indexes in MongoDB?

    • AB-TreeCorrect answer
    • BHash table
    • CLinked list
    • DBinary heap

    Why this is the answer

    MongoDB uses a B-Tree structure for single field indexes, enabling logarithmic traversal and efficient searches, range queries, and sorting.

  2. Question 18Multiple Select

    What statements about multikey indexes are true? Select all that apply.

    • AA compound index cannot include more than one array field.Correct answer
    • BMongoDB creates a multikey index when the indexed field is an array.Correct answer
    • CEach element in an indexed array receives an index entry.Correct answer
    • DA multikey index can include multiple array fields to improve performance.

    Why this is the answer

    A single compound multikey index cannot contain more than one array field, and MongoDB indexes each array element separately, improving array query selectivity but increasing index size.

  3. Question 19Interactive

    Based on the index created in the code, which query cannot be efficiently supported?

    • AFilter on first_name onlyCorrect answer
    • BFilter on last_name only
    • CFilter on both last_name and first_name
    • DFilter on last_name and sort by first_name

    Why this is the answer

    Index prefixes are last_name and last_name+first_name. A filter on first_name alone cannot use this index because first_name is not a leading prefix.

  4. Question 20Single Choice

    According to the ESR rule, what is the recommended field order for a compound index?

    • AEquality, Sort, RangeCorrect answer
    • BRange, Sort, Equality
    • CSort, Equality, Range
    • DEquality, Range, Sort

    Why this is the answer

    ESR stands for Equality, Sort, Range. Ordering fields this way narrows matches first, supports sorting, and applies range filters last.

  5. Question 21Multiple Select

    Which statements about indexing overhead are true? Select all that apply.

    • AEach index adds write overhead to insert, update, and delete operations.Correct answer
    • BAdding more indexes always improves query performance.
    • CA single field index cannot fully optimize a query that filters on two fields.Correct answer
    • DA sparse index contains entries only for documents that have the indexed field.Correct answer

    Why this is the answer

    Indexes must be updated on writes; more indexes can slow write-heavy loads. A single field index only helps with one indexed field, and sparse indexes omit documents missing the field.

  6. Question 22Interactive

    Why will MongoDB reject the compound index creation shown in the code?

    • AIt attempts to index two array fields in one compound index.Correct answer
    • BIt violates the ESR field ordering rule.
    • CIt uses ascending order instead of descending order.
    • DIt does not include a sort field.

    Why this is the answer

    MongoDB prohibits a compound multikey index with more than one array field to avoid a Cartesian product explosion of index entries.

Data Modeling

6 questions in this domain

  1. Question 23Single Choice

    What data structure does MongoDB use to implement single field indexes?

    • AB-TreeCorrect answer
    • BHash table
    • CLinked list
    • DUnordered heap

    Why this is the answer

    MongoDB implements single field indexes using a B-Tree, giving logarithmic time complexity for lookups, range queries, and sorting operations.

  2. Question 24Multiple Select

    Which statements about single field indexes in MongoDB are correct? Select all that apply.

    • AThe ascending/descending direction is largely irrelevant for equality matches.Correct answer
    • BIndex direction is crucial when the index is used to support a sort operation.Correct answer
    • CA sparse index contains entries for documents that are missing the indexed field.
    • DAn index on a low-cardinality field such as gender is always more efficient than an index on user_id.

    Why this is the answer

    For equality matches, index direction does not matter, but for sort operations it does. Sparse indexes omit documents missing the field, and high-cardinality fields provide better selectivity.

  3. Question 25Interactive

    You execute the MongoDB command shown in the code block on a collection where the indexed field contains arrays. What type of index is created?

    • AMultikey indexCorrect answer
    • BSparse index
    • CCompound index
    • DWildcard index

    Why this is the answer

    When a single indexed field contains an array, MongoDB automatically creates a multikey index with an entry for each array element.

  4. Question 26Single Choice

    An index is defined as { status: 1, created_at: 1 }. According to the index prefix rule, which query can use this index?

    • AA filter on status onlyCorrect answer
    • BA filter on created_at only
    • CA filter on neither field
    • DA sort on created_at only

    Why this is the answer

    Index prefixing allows a compound index to support queries on a prefix of its fields. { status: 1, created_at: 1 } can support status-only filters but not created_at-only filters.

  5. Question 27Multiple Select

    According to the ESR rule, what is the recommended order for fields in a compound index? Select all that apply.

    • AEquality fields should be placed before sort fields.Correct answer
    • BSort fields should be placed after equality fields.Correct answer
    • CRange fields should be placed before equality fields.
    • DRange fields should be placed after sort fields.Correct answer

    Why this is the answer

    ESR means Equality first, Sort second, and Range last. This ordering maximizes selectivity and avoids blocking sorts.

  6. Question 28Interactive

    Why does MongoDB reject the compound index creation shown in the code block?

    • AA compound index cannot include more than one array field.Correct answer
    • BArray fields cannot be indexed at all.
    • CIndex fields must be ordered alphabetically.
    • DThe same field cannot appear twice in an index.

    Why this is the answer

    MongoDB prohibits compound multikey indexes on more than one array field to avoid a Cartesian product explosion of index entries.

Indexes

6 questions in this domain

  1. Question 29Single Choice

    Which data structure does MongoDB use when creating a single field index?

    • AB-TreeCorrect answer
    • BHash Table
    • CLinked List
    • DLSM Tree

    Why this is the answer

    MongoDB uses a B-Tree structure for single field indexes, enabling logarithmic lookups and efficient traversal for searches, ranges, and sorts.

  2. Question 30Multiple Select

    Select all the true statements about single field indexes in MongoDB.

    • AIndex direction is irrelevant for equality matches.Correct answer
    • BIndex direction is crucial for supporting sort operations.Correct answer
    • CIndexing a low-cardinality field always outperforms a collection scan.
    • DEvery stored index adds overhead to write operations.Correct answer

    Why this is the answer

    A single field index can be traversed in both directions, so direction matters mainly for sorts. Indexes always add write overhead, and low-cardinality fields are not guaranteed to outperform collection scans.

  3. Question 31Interactive

    Look at the index creation command in the code block. If the indexed field contains arrays in some documents, which type of index will be created by MongoDB?

    • AMultikey indexCorrect answer
    • BSparse index
    • CText index
    • DCompound index

    Why this is the answer

    When a single indexed field contains an array, MongoDB creates a multikey index, with one index entry per array element.

  4. Question 32Single Choice

    According to the ESR rule, what is the recommended order of fields in a compound index?

    • AEquality, then Sort, then RangeCorrect answer
    • BRange, then Sort, then Equality
    • CSort, then Equality, then Range
    • DEquality, then Range, then Sort

    Why this is the answer

    ESR stands for Equality, Sort, Range. Equality fields first narrow the search space, sort fields provide ordering, and range filters are applied last.

  5. Question 33Multiple Select

    Select all true statements about compound indexes and the index prefix rule.

    • AAn index on { a: 1, b: 1 } efficiently supports queries on b alone without a
    • BField order in a compound index does not affect which queries can use it
    • CThe order of fields in a compound index is significant because of the prefix rule.Correct answer
    • DA compound index can only be used when all its fields appear with equality matches

    Why this is the answer

    The prefix rule means the leading field must be part of the query. An index on { a: 1, b: 1 } supports a alone or a and b together, but not b alone.

  6. Question 34Interactive

    Based solely on the compound index in the code block, which query pattern is NOT efficiently supported?

    • AA query filtering only on first_nameCorrect answer
    • BA query filtering only on last_name
    • CA query filtering on both last_name and first_name
    • DA sort on last_name and first_name

    Why this is the answer

    Because of the prefix rule, the index can support last_name alone or last_name plus first_name, but not first_name alone because the leading field is absent.

Performance

6 questions in this domain

  1. Question 35Single Choice

    Which data structure does MongoDB use to implement single field indexes?

    • AHash table
    • BB-TreeCorrect answer
    • CLinked list
    • DLSM tree

    Why this is the answer

    MongoDB uses a B-Tree structure for single field indexes, enabling logarithmic lookup, range queries, and sorting efficiency.

  2. Question 36Multiple Select

    Which statements are true regarding single field indexes? Select all that apply.

    • AA single field index can be traversed in both directions.Correct answer
    • BAn index on a low-cardinality field is always more efficient than one on a high-cardinality field.
    • CEvery index adds overhead to insert, update, and delete operations.Correct answer
    • DA single field index on an array is known as a wildcard index.

    Why this is the answer

    Single field indexes are bidirectional and impose write overhead. High-cardinality fields are more selective, and array indexes are multikey, not wildcard.

  3. Question 37Interactive

    Review the index creation command in the code block. What type of index does it create?

    • AAscending single field indexCorrect answer
    • BDescending single field index
    • CCompound index
    • DMultikey index

    Why this is the answer

    The code creates an ascending index on the status field. It is a single field index because only one field is specified.

  4. Question 38Single Choice

    Why is an index on a high-cardinality field such as user_id more efficient than one on a low-cardinality field such as gender?

    • AIt allows the engine to discard non-matching documents more quickly.Correct answer
    • BIt eliminates the need for any index on other fields.
    • CIt guarantees that all queries will use the index.
    • DIt reduces the overhead of every write operation.

    Why this is the answer

    High-selectivity indexes narrow the search space quickly by discarding many non-matching documents, making queries more efficient.

  5. Question 39Multiple Select

    Which statements about multikey indexes are correct? Select all that apply.

    • AAn entry is created for every element in the indexed array.Correct answer
    • BA multikey index is automatically created when the indexed field contains an array.Correct answer
    • CA compound index can include two different array fields.
    • DMultikey indexes are the same as wildcard indexes.

    Why this is the answer

    Multikey indexes are automatic for array fields and create one entry per element. MongoDB prohibits compound multikey indexes with multiple array fields.

  6. Question 40Interactive

    The code block creates an index on the email field. What characteristic does this index have?

    • ASparse indexCorrect answer
    • BPartial index
    • CCompound index
    • DMultikey index

    Why this is the answer

    The sparse: true option creates a sparse index, which contains entries only for documents that have the indexed field.

Frequently asked questions

Everything about the MongoDB Certified Associate Developer question bank and how to use it.