Courseiva
Indexing →easyMultiple Choice

C100DEV Indexing Practice Question

A developer needs to ensure that a `users` collection does not contain two documents with the same email address. Which index type should be created on the `email` field?

⚠ Common exam trap

Many exam-takers confuse sparse or partial indexes with unique indexes, thinking that any special index type can enforce uniqueness.

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 unique index

To prevent duplicate email addresses, a unique index on the email field is required. Unique indexes enforce that each value appears at most once. Other index types like sparse, partial, or hashed do not provide this guarantee. A unique index is the correct choice to maintain data integrity for the email field.

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 sparse index

    Why it's wrong here

    A sparse index only includes documents that have the indexed field. It does not enforce uniqueness; it merely reduces index size by excluding documents missing the field. While it can be combined with unique, a sparse index alone does not prevent duplicate email addresses. It is used for optional fields to avoid indexing nulls, not for enforcing uniqueness.

  • ✗

    A partial index

    Why it's wrong here

    A partial index includes only documents that meet a specified filter expression. It can be unique, but by itself it does not enforce uniqueness across all documents. If the filter excludes some documents, those are not indexed and could contain duplicates. To enforce uniqueness on email for all documents, a unique index without a filter is needed. A partial index alone is insufficient.

  • ✗

    A hashed index

    Why it's wrong here

    A hashed index stores hashes of field values and is used for sharding or equality queries. It does not support uniqueness constraints. In fact, hashed indexes cannot be unique. They are designed for even data distribution, not for enforcing data integrity such as unique email addresses. Thus, a hashed index would not prevent duplicate emails.

  • ✓

    A unique index

    Why this is correct

    A unique index on the email field enforces that no two documents can have the same value for email. This prevents duplicate email addresses at the database level. MongoDB will reject inserts or updates that would violate the uniqueness constraint, ensuring data integrity. This is the standard way to enforce uniqueness on a field.

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.