C100DEV Data Modeling Practice Question
A library management system stores book information in a `books` collection. Each book document includes fields such as `title`, `author`, `ISBN`, and `genre`. The application frequently queries books by `genre` and `author`. Which index strategy is most appropriate to optimize these queries?
⚠ Common exam trap
The trap here is assuming that separate single-field indexes are equivalent to a compound index, or that a text index can handle exact-match queries, when in fact a compound index is specifically optimized for the query pattern.
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 compound index on `{ genre: 1, author: 1 }`.
A compound index on `{ genre: 1, author: 1 }` efficiently supports queries that filter on both fields or on `genre` alone, leveraging the index prefix. It also supports sorting by `genre` and `author`, which aligns with common library queries. Single-field indexes may require index intersection, which is less efficient, while text and hashed indexes are unsuitable for exact-match queries.
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 compound index on `{ genre: 1, author: 1 }`.
Why this is correct
A compound index on `genre` and `author` supports queries that filter on both fields or on `genre` alone, because the index prefix can be used. Since the application frequently queries by both `genre` and `author`, this index will efficiently serve those queries. It also supports queries that sort by `genre` and then `author`, which is common in library applications.
- ✗
Create a text index on `title`, `author`, and `genre`.
Why it's wrong here
A text index is designed for full-text search, not for exact-match queries on fields like `genre` and `author`. Text indexes tokenize and stem words, which is not suitable for exact matches or sorting. Using a text index for these queries would be inefficient and would not support the expected query patterns. It also has limitations, such as only one text index per collection.
- ✗
Create a hashed index on `genre` and a regular index on `author`.
Why it's wrong here
Hashed indexes are used for equality matches but do not support range queries or sorting. Since the application may need to sort by `genre` or perform range queries, a hashed index on `genre` is inappropriate. Additionally, combining a hashed index with a regular index does not create a compound index, so queries filtering on both fields would not be optimally served.
- ✗
Create a single-field index on `genre` and another single-field index on `author`.
Why it's wrong here
While single-field indexes can be used together via index intersection, MongoDB may not always choose to intersect them, and intersection is less efficient than a compound index for queries that filter on both fields. A compound index provides better performance and is more predictable. For queries that filter on both `genre` and `author`, a compound index is the optimal choice.
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 →
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.