C100DEV Data Modeling Practice Question
A healthcare application stores patient records. Each patient document includes a `medications` array of subdocuments, each with `name`, `dosage`, and `frequency`. The application needs to query patients who are taking a specific medication with a specific dosage. The array is expected to grow to hundreds of entries per patient. Which schema design best supports efficient querying and management of this data?
⚠ Common exam trap
The trap here is assuming that embedding with a multikey index is always sufficient, when in fact unbounded arrays can degrade performance and complicate updates, making a separate collection more appropriate.
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
✓
Move medications to a separate `medications` collection with documents referencing the patient ID, and create a compound index on `{ name: 1, dosage: 1, patientId: 1 }`.
Separating medications into their own collection prevents unbounded array growth in patient documents and enables efficient querying with a compound index. The index on `name`, `dosage`, and `patientId` supports queries for patients taking a specific medication with a specific dosage. This design scales well and simplifies management of individual medication records.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Embed the `medications` array as is, and create a multikey index on `medications.name` and `medications.dosage`.
Why it's wrong here
While a multikey index can support queries on array elements, embedding hundreds of medication subdocuments per patient can lead to large documents and potential performance issues. Each index entry is created for each array element, which can bloat the index. Additionally, updating or querying specific medications within a large array can be inefficient. This approach does not scale well for hundreds of entries.
- ✓
Move medications to a separate `medications` collection with documents referencing the patient ID, and create a compound index on `{ name: 1, dosage: 1, patientId: 1 }`.
Why this is correct
Separating medications into their own collection avoids unbounded array growth in patient documents and allows for efficient querying with a compound index on `name`, `dosage`, and `patientId`. This design supports queries for specific medication and dosage across patients, and it scales well as the number of medications grows. It also simplifies updates and deletions of individual medication records.
- ✗
Use the Subset Pattern to store only the most recent 10 medications in the patient document and archive older medications in a separate collection.
Why it's wrong here
The Subset Pattern is useful when only a subset of data is frequently accessed, such as recent orders. However, in a healthcare context, all medications may be relevant for queries, not just the most recent ones. Archiving older medications could lead to incomplete query results. This pattern does not address the need to query any medication by name and dosage efficiently.
- ✗
Use the Bucket Pattern to group medications into buckets of 50 per patient document, and index the `name` and `dosage` fields.
Why it's wrong here
The Bucket Pattern is typically used for time-series data, not for grouping related subdocuments like medications. While it reduces the number of documents, it complicates queries that need to find a specific medication across buckets. The application would need to query multiple buckets, and the index would still need to cover all elements. This adds complexity without clear benefits.
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 →
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.