Courseiva

C100DEV MongoDB Overview and Document Model Practice Question

A developer is designing a MongoDB collection to store user profiles. Each profile document includes fields for name, email, and an array of phone numbers. The developer wants to ensure that the email field is unique across all documents. Which MongoDB feature should be used to enforce this constraint?

⚠ Common exam trap

The trap here is assuming that schema validation can enforce uniqueness, but validation rules operate per document and cannot reference other documents.

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

✓

Unique index on the email field

A unique index on the email field is the only reliable way to enforce uniqueness in MongoDB. It guarantees that no two documents can have the same email value, even under concurrent operations. Schema validation, sharding, and application-level checks cannot provide this guarantee. The unique index also speeds up queries that filter by email.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Sharding the collection on the email field

    Why it's wrong here

    Sharding distributes data across multiple servers but does not enforce uniqueness. In fact, a sharded collection can have duplicate email values unless a unique index is also created. Sharding is for scalability, not for constraint enforcement. It would not prevent duplicate emails.

  • ✗

    Schema validation with $jsonSchema

    Why it's wrong here

    Schema validation can enforce that the email field exists and is a string, but it cannot enforce uniqueness across documents. Validation rules apply per document and do not have access to other documents. Therefore, it cannot prevent duplicate emails. Unique constraints must be enforced by an index.

  • ✗

    Application-level check before insert

    Why it's wrong here

    Checking for duplicates in the application code before inserting is not reliable because of race conditions. Two concurrent inserts could both pass the check and then both insert, creating duplicates. MongoDB's unique index provides atomic enforcement at the database level, which is necessary for correctness in a multi-user environment.

  • ✓

    Unique index on the email field

    Why this is correct

    A unique index on the email field ensures that no two documents can have the same email value. MongoDB will reject any insert or update that would create a duplicate key. This is the standard way to enforce uniqueness in a collection, and it works across all documents. It also improves query performance for lookups by email.

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 →

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.