Courseiva
Indexing →mediumMultiple Choice

C100DEV Indexing Practice Question

You need to ensure that values in the 'email' field are unique across all documents in a collection, but documents where the 'email' field is missing should not violate this constraint. How should you create this index?

⚠ Common exam trap

Candidates often try to use a standard unique index, which fails because it treats missing fields as null, causing conflicts if multiple documents lack the email 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

✓

Create a unique partial index with a filter expression requiring email to exist

Partial indexes allow you to restrict the indexing operation to a subset of documents that meet a specified filter expression. By combining a unique constraint with a partial filter expression requiring the field to exist, you prevent duplicate values for present fields while allowing multiple documents to omit the field entirely.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Create a standard unique index on the email field

    Why it's wrong here

    A standard unique index treats a missing email as null and rejects the second document lacking the field, so absent values collide. It is tempting because plain unique indexes are the normal way to enforce one-of-a-kind values, and they work correctly when every document is guaranteed to contain the field.

  • ✗

    Create a sparse index on the email field without uniqueness

    Why it's wrong here

    A sparse index omits documents that do not contain the indexed field from the index structure, but omitting the unique property fails to enforce the core business requirement that present email addresses must remain strictly unique.

  • ✗

    Create a wildcard index on the email field

    Why it's wrong here

    A wildcard index indexes every field path, which cannot enforce uniqueness on email and still permits duplicate addresses. It is tempting because wildcard indexes genuinely serve ad-hoc queries over unpredictable field names, but uniqueness constraints require a single-field index with a partial filter.

  • ✓

    Create a unique partial index with a filter expression requiring email to exist

    Why this is correct

    A partial index applies the uniqueness constraint only to documents matching its filter expression, so requiring the email field to exist excludes documents lacking it. This satisfies the constraint that missing-email documents must not trigger duplicate key violations.

About these practice questions

One of 259 original C100DEV practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.