Courseiva

C100DEV MongoDB Overview and Document Model Practice Question

A development team is building a MongoDB application to store user profiles. They want to enforce that every user document contains an 'email' field of type string, and they want documents that violate this rule to be rejected at insert time. Which MongoDB feature should they use?

⚠ Common exam trap

The trap here is assuming that a unique index enforces field presence and type, when it only enforces uniqueness and only for documents that contain the field.

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 the collection's validator option

MongoDB's JSON Schema validation allows developers to enforce a schema on a collection while still accommodating flexible fields. By defining a validator with $jsonSchema, the team can require the 'email' field and ensure it is a string. This provides server-side enforcement, ensuring that any insert or update that violates the schema is rejected, regardless of the client used.

Answer analysis

Option-by-option breakdown

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

  • ✓

    JSON Schema validation with the $jsonSchema operator in the collection's validator option

    Why this is correct

    MongoDB supports schema validation at the collection level using the $jsonSchema operator, which allows specifying required fields, BSON types, and other constraints. When configured, inserts and updates that do not match the schema are rejected, providing data integrity while still allowing flexible fields not covered by the schema.

  • ✗

    Storing the email in a separate collection with a reference

    Why it's wrong here

    Normalizing the email into a separate collection does not enforce that the user document contains an email field or that it is a string. It simply changes the data model, adding complexity without providing the desired validation. The requirement is for validation, not normalization.

  • ✗

    Unique index on the 'email' field

    Why it's wrong here

    A unique index ensures that no two documents have the same email value, but it does not enforce the presence of the field or its type. Documents missing the 'email' field would be allowed unless the index is sparse, and type enforcement is not provided. It addresses duplication, not schema validation.

  • ✗

    Application-level validation using Mongoose schema definitions

    Why it's wrong here

    Mongoose provides schema validation in the application layer, but it only applies when using Mongoose and does not protect against direct database operations or other clients. The requirement is to reject invalid documents at insert time within MongoDB itself, so server-side validation is needed.

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.