C100DEV MongoDB Overview and Document Model Practice Question
A developer is building an inventory system for a hardware store. Each item document needs to store the product's name, a unique SKU, the quantity on hand, and a list of compatible replacement part numbers. The developer wants to ensure that the `sku` field is always present and is a string, while still allowing other fields to vary between item types. Which MongoDB feature should the developer use to enforce this requirement?
⚠ Common exam trap
The trap here is assuming that a unique index also enforces field presence and type, when it only enforces uniqueness among existing values.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
JSON Schema validation with the `$jsonSchema` operator in a collection validator
The requirement is to enforce a specific field and type at write time while allowing other fields to vary. MongoDB's schema validation with `$jsonSchema` is designed for exactly this: you can specify required fields and BSON types in a validator, and the server rejects documents that do not comply. This keeps the collection flexible for other fields but guarantees the `sku` contract.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The `$exists` query operator in all read operations
Why it's wrong here
The `$exists` operator is used in queries to filter documents based on whether a field is present, but it does not enforce anything at write time. A developer could still insert an item without a `sku` and only discover the problem later when a query returns no results, which does not meet the requirement of always enforcing presence.
- ✗
A unique index on the `sku` field
Why it's wrong here
A unique index prevents duplicate `sku` values, which is useful for uniqueness, but it does not require the field to be present or enforce that its value is a string. A document missing `sku` would still be accepted by a unique index, so this does not satisfy the requirement that `sku` always exists and is a string.
- ✓
JSON Schema validation with the `$jsonSchema` operator in a collection validator
Why this is correct
Collection validators using `$jsonSchema` let you require specific fields and types, such as `sku` as a string, while leaving other fields flexible. This directly enforces the rule at the database level for every insert or update, which matches the developer's need to guarantee `sku` presence and type without restricting the rest of the document shape.
- ✗
Storing the `sku` in a separate collection and using `$lookup`
Why it's wrong here
Moving `sku` to a separate collection and using `$lookup` changes the data model but does not enforce that each item document has a `sku`. The item document could still be inserted without a `sku`, and the application would need to join to another collection, adding complexity without providing the required validation.
About these practice questions
This C100DEV question is part of Courseiva's 259-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official MongoDB exam blueprint
This C100DEV practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DEV exam.