Courseiva

C100DEV MongoDB Overview and Document Model Practice Question

An application stores customer profiles in a MongoDB collection. A developer notices that documents created by different services have inconsistent shapes: some use a string for phone, others an array of strings, and some omit the field entirely. The team wants to enforce a consistent structure for new writes while still allowing existing documents to remain. Which MongoDB feature should they use?

⚠ Common exam trap

The trap here is assuming that indexes enforce document structure, when in MongoDB only schema validation rules applied to the collection can reject writes that do not match the declared shape.

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

✓

A JSON Schema validator attached to the collection with the $jsonSchema operator and validationLevel set to strict.

MongoDB supports schema validation through the $jsonSchema operator, configured on a collection with collMod. Setting validationLevel to strict applies the rules to all inserts and updates, so new writes must match the declared structure. Existing documents that are not modified remain untouched, which satisfies the requirement to leave current data as is while enforcing consistency going forward.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    A unique index on the phone field, which forces every document to use the same BSON type for that field.

    Why it's wrong here

    A unique index enforces uniqueness of values, not their type or presence. Documents could still store phone as a string in one document and an array in another, and omitted fields would not be prevented. This option confuses value uniqueness with structural validation and does not produce the consistent shape the team wants.

  • ✗

    A partial index with a filter expression that excludes documents lacking the phone field.

    Why it's wrong here

    A partial index only controls which documents are indexed; it does not constrain the types or required fields in stored documents. Documents with different phone representations would still be accepted. This option confuses indexing behavior with write-time validation and would not enforce the consistent structure the team is seeking.

  • ✗

    A change stream that watches the collection and rejects documents whose shape differs from a template.

    Why it's wrong here

    Change streams report changes after they have been committed, so they cannot prevent an invalid document from being written. They are suitable for reacting to events, not for enforcing structure at write time. Using one to police document shape would be too late and would add unnecessary complexity compared with server-side validation.

  • ✓

    A JSON Schema validator attached to the collection with the $jsonSchema operator and validationLevel set to strict.

    Why this is correct

    $jsonSchema lets the team declare required fields and BSON types, and attaching it with collMod applies it to the collection. Setting validationLevel to strict enforces the rules on all inserts and updates, including existing documents when they are modified, which matches the goal of consistent new writes while leaving untouched documents in place. This is the native MongoDB mechanism for schema validation.

About these practice questions

Courseiva writes every C100DEV question from scratch — 259 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.