Limited-Time Offer: Enjoy 50% Savings! Coupon code: 50OFF Use it at checkout
Skip to content

Free MongoDB Certified Database Administrator C100DBA Exam Questions

Last updated: · 11 practice questions with answers and explanations

Page: 1 / 12 Total 172 questions

Want more questions? Get Premium Access.

Question 1

New Single answer

Topic: Philosophy & Features

Skill tested: Compares JSON and BSON representation tradeoffs for document storage and query performance.

A telemetry service stores device readings as MongoDB documents and frequently filters on a numeric timestamp, a Boolean health flag, and nested numeric sensor values. The application team proposes retaining a JSON-formatted copy of every record in a string field because JSON is human-readable and easy to exchange. The collection is large, and the operational requirement is to query these fields directly without parsing each record in application code. The team also wants to preserve efficient storage and traversal of typed values. Which design best meets these requirements?

Correct Answer: B. Store the readings as normal BSON documents, using appropriate numeric and Boolean BSON types for fields that queries access.
Explanation:

MongoDB stores documents in BSON, a binary representation that supports typed values and efficient traversal, so numeric and Boolean fields can be queried and indexed directly. A JSON string is just a scalar string to MongoDB; its internal properties are not independently queryable or indexable as document fields. Encoding everything as text discards useful type information, while storing duplicate complete representations increases storage and write costs without helping the stated query requirement. JSON remains useful for interchange, but the queryable collection should use structured BSON documents.

Question 2

New Single answer

Topic: CRUD

Skill tested: Selects an update operator strategy that changes multiple fields and inserts missing documents.

A billing service receives one authoritative status record per invoice, identified by `invoiceId`. On each delivery, the service must set `state` and `lastReceivedAt` to the incoming values, increment `deliveryCount`, and create the document if the invoice has never been seen. Existing unrelated fields must remain unchanged. The service currently issues a read followed by an insert or update, but concurrent deliveries can race and create duplicate-key errors. Which operation is the most appropriate atomic approach?

Correct Answer: C. Use `updateOne` with an equality filter on `invoiceId`, `$set` for `state` and `lastReceivedAt`, `$inc` for `deliveryCount`, and `upsert: true`.
Explanation:

`updateOne` with `upsert: true` performs the match and write as one update operation. `$set` changes the two supplied fields without removing unrelated fields, and `$inc` increments the counter or initializes it to the increment amount when creating a new document. A replacement upsert would replace rather than preserve unspecified fields. The proposed projection pipeline would discard data and does not address the required counter update. Insert-then-catch reintroduces extra round trips and race-handling complexity.

Question 3

New Multiple answers

Topic: CRUD

Skill tested: Uses an update aggregation pipeline to compute and conditionally preserve document fields during upsert.

A catalog team receives partial inventory events keyed by `sku`. An event may include `available` and `warehouse`, while omitted fields must retain their current values. For a newly encountered SKU, missing `available` must default to zero and missing `warehouse` to `"unassigned"`; `updatedAt` must always be set to the event time. The update must be a single upsert, and the team wants the field values to be computed from both the incoming event and the matched document. Select TWO actions that meet these requirements.

Correct Answer: C. Use `updateOne` with an equality filter on `sku`, an aggregation update pipeline, and `upsert: true`.; E. In the pipeline, use `$ifNull` with the incoming value and the existing field, followed by the stated defaults where both are absent.
Explanation:

An aggregation pipeline update can derive new values from the current document and supplied event, and `updateOne` supports upsert semantics. `$ifNull` can choose an incoming value when present, otherwise preserve the existing value, with a final default for a newly inserted document lacking either value. The pipeline can also set `updatedAt` unconditionally. `$setOnInsert` does not provide the required general computation from old and incoming values, replacement would discard omitted fields, and `$out` is an aggregation output stage rather than an update-pipeline stage.

Question 4

New Single answer

Topic: Indexing and Performance

Skill tested: Chooses a compound index based on equality predicates, sort order, and query selectivity.

An order-management collection is growing rapidly. A frequent query filters on `tenantId` and `status`, sorts by `createdAt` descending, and returns a small page of results. Measurements show both filters are commonly supplied, and the query plan currently performs a collection scan followed by an in-memory sort. Other workloads occasionally filter by `tenantId` alone. The team can add one index but wants to avoid indexing every field independently. Which index is the best fit for the dominant query while retaining useful prefix support?

Correct Answer: B. `{ tenantId: 1, status: 1, createdAt: -1 }`
Explanation:

The compound index puts equality fields first and the sort field afterward, allowing MongoDB to narrow by tenant and status and obtain results in the requested `createdAt` order without a separate in-memory sort. The `{tenantId: 1}` prefix also supports queries on tenant alone. Putting the sort field first is less aligned with the equality-constrained access pattern, and omitting `tenantId` leaves a major predicate unsupported. Separate indexes may sometimes be combined, but do not provide the same direct compound ordering and may require extra work.

Question 5

New Single answer

Topic: Indexing and Performance

Skill tested: Evaluates compound-index field order and multikey limitations for array query patterns.

A support platform stores tickets with scalar `organizationId` and an array of `labels`. Its most expensive query matches one organization and requires both `labels` values `"urgent"` and `"customer-impact"` to be present. The team has confirmed that the query uses `$all`, and the collection has no other array field in the proposed index. A new index must support this query without creating separate per-organization indexes. Which index is the most appropriate starting point?

Correct Answer: D. `{ organizationId: 1, labels: 1 }`
Explanation:

A compound multikey index with scalar `organizationId` followed by the `labels` array can support the organization equality predicate and label membership lookups. MongoDB permits a compound multikey index when only one indexed field is an array for each document, as in this scenario. Repeating the array field in an index is not a valid way to improve `$all`, and a text index serves text-search semantics rather than this exact membership query. Reversing the order may be useful for different query workloads, but the stated organization-scoped query favors this order.

Question 6

New Multiple answers

Topic: Server Administration

Skill tested: Configures MongoDB authentication and identifies operational data and log path settings.

A company is preparing a standalone MongoDB 7.0 server for an internal application. The server currently accepts connections without credentials, and the requirement is to use MongoDB's built-in user authentication. The administrator will create the first user locally before enabling authentication, and must keep database files and diagnostic logs under separate approved filesystem directories. The deployment uses a configuration file rather than command-line options. Which TWO actions satisfy the requirements?

Correct Answer: A. Set `storage.dbPath` to the approved database directory and `systemLog.path` to the approved log file path.; C. Create the initial user in the `admin` database, then configure `security.authorization: enabled` and restart the server.
Explanation:

MongoDB's access-control enforcement is enabled with `security.authorization: enabled`; creating the initial administrative user before turning it on avoids locking out administration. The database file location is configured with `storage.dbPath`, while file logging is configured with `systemLog.path`. Selecting a SCRAM mechanism controls supported authentication mechanisms but does not itself enable authorization. Binding to all interfaces is a network exposure decision, not authentication, and JavaScript settings or users in `local` do not satisfy this access-control setup.

Question 7

New Single answer

Topic: Application Administration

Skill tested: Enables MongoDB auditing and applies least-privilege role-based access to application accounts.

A regulated service requires an audit trail of authorization-related activity and a restricted application account that can read and update documents only in the `orders` collection of the `commerce` database. The production deployment is a MongoDB Enterprise replica set; the application does not need user or role administration, database-wide access, or access to other collections. Which approach best satisfies both requirements?

Correct Answer: C. Enable auditing in the server configuration with an appropriate audit destination/filter, then grant the application a custom role scoped to the `commerce.orders` resource with only required actions.
Explanation:

MongoDB auditing is configured for supported Enterprise deployments through server audit settings, including an audit destination and optional filtering. A custom role can restrict privileges to the required database and collection resource and grant only the read and write actions the application needs. The built-in `readWrite` role is broader than the specified collection-level scope, and profiling is not equivalent to a security audit trail. `root` violates least privilege, while enabling authorization alone does not automatically turn on auditing.

Question 8

New Single answer

Topic: Replication

Skill tested: Diagnoses election eligibility using secondary lag and replica-set member priorities.

A three-member replica set has one primary and two data-bearing secondaries. During a network disruption, one secondary becomes substantially behind the primary and repeatedly fails to catch up; the other secondary remains current. The lagging member has priority 2, the current member has priority 1, and the primary has priority 1. Operators report that election behavior is surprising and are reviewing member configuration before restoring normal service. What is the best recommendation?

Correct Answer: A. Inspect the lagging member's replication state and oplog window, then lower its priority or set it non-voting/non-electable until it can remain sufficiently current.
Explanation:

Priority influences which eligible member is preferred for primary selection; it does not make a stale or unhealthy member current or override election eligibility and data-consistency rules. Operators should examine replication lag, member state, and whether the oplog still contains the operations needed to catch up. A lagging high-priority member can create undesirable election preferences, so lowering its priority or temporarily making it non-electable is safer while resolving the underlying lag. Raising priority does not accelerate replication, and lower-priority members can participate in elections.

Question 9

New Multiple answers

Topic: Replication

Skill tested: Uses replication status and oplog-window evidence to isolate secondary lag and prevent unsafe promotion.

After a storage incident, a replica-set secondary remains in `RECOVERING`, and its reported replication lag continues to increase. The primary is healthy, but administrators are considering forcing an election to move writes to the recovering node. The secondary's last applied operation is older than the oldest operation currently retained in the primary's oplog. They need to diagnose the failure and restore service without promoting a member that cannot catch up. Select TWO appropriate actions.

Correct Answer: A. Compare `rs.printSecondaryReplicationInfo()` and `rs.status()` output with the primary's oplog window to confirm the secondary has fallen behind retained history.; D. Resynchronize the secondary from a current data-bearing member or a fresh initial sync, then verify it catches up before allowing it to be electable.
Explanation:

The secondary's last applied operation predates the primary's oldest retained oplog entry, so the missing history is no longer available for ordinary catch-up. Replication status and lag reporting help confirm that condition. The appropriate recovery is a resynchronization, typically an initial sync from a suitable member or a fresh data copy, followed by validation that it is current before it can be considered for promotion. An election cannot recreate rolled-off operations, changing priority does not repair replication history, and disabling replication on the primary is neither a safe nor effective recovery method.

Question 10

New Single answer

Topic: Sharding

Skill tested: Selects a shard key that distributes writes and supports the collection's dominant query pattern.

A SaaS platform is planning to shard a rapidly growing event collection. Nearly every query specifies `tenantId`, but a few large tenants generate most writes. The current `tenantId` values are monotonically assigned and new tenants cluster at the high end of the key space. The team wants to avoid a single hot shard, preserve targeted tenant queries where feasible, and accepts that queries spanning many tenants may scatter. Which shard-key approach is the best fit to evaluate first?

Correct Answer: C. Use a hashed shard key on `tenantId` to distribute tenant values across chunks while retaining equality targeting for a specified tenant.
Explanation:

A hashed `tenantId` key distributes distinct tenant values across the shard-key space, reducing the risk that monotonically increasing tenant identifiers direct new ranges to one shard. Equality queries specifying the shard key can be targeted. The caveat is that a very large individual tenant remains concentrated on a shard, so workload distribution must be monitored and the key validated against actual tenant skew. Ascending tenant values can hotspot as new values arrive; ascending event time is particularly prone to a moving write hotspot. A random unrelated key does not make tenant queries inherently targeted.

Question 11

New Multiple answers

Topic: Sharding

Skill tested: Assesses shard suitability and shard-key cardinality, frequency, and write-distribution tradeoffs.

An analytics collection contains 80 GB of records and is growing by 1 GB per month. Current workload fits on one replica set, but forecasts show it will remain below the available storage and working-set capacity for several years. Queries commonly filter by `region` and a time range; writes arrive continuously, and `eventTime` is monotonically increasing. The team is considering sharding now solely to improve query speed. If sharding is later justified, it wants to avoid an avoidable write hotspot. Select TWO sound recommendations.

Correct Answer: C. Do not shard solely because the collection is large; first confirm that a single replica set cannot meet capacity or performance requirements.; E. If sharding becomes necessary, assess a shard key that includes a suitably distributed component and aligns with important query filters, testing its cardinality and workload distribution.
Explanation:

Sharding adds operational and query-routing complexity; it should address a demonstrated capacity or performance need, not collection size alone when one replica set has ample headroom. If scale-out becomes necessary, shard-key design must balance distribution and useful query targeting. A monotonically increasing key can concentrate new inserts at the active high end, while low-cardinality fields such as a Boolean flag provide poor distribution. `region` may help some queries but can be badly skewed, so cardinality and actual workload must be evaluated rather than assumed.