Courseiva
CRUD Operations →hardMultiple Choice

C100DBA CRUD Operations Practice Question

What happens when you perform a find() query on a collection where the projection includes both an inclusion and an exclusion for different fields?

⚠ Common exam trap

Candidates often assume that mixing field inclusions and exclusions works as long as they apply to different fields, missing the rule that errors out.

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

✓

The query returns an error.

MongoDB enforces strict rules regarding field projection. You cannot mix inclusions and exclusions in the same projection object, with the exception of the _id field. This design choice ensures predictable behavior for the result set. Understanding this limitation is important for developers when they need to fetch specific subsets of data while omitting others, as it prevents common errors during query construction.

Answer analysis

Option-by-option breakdown

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

  • ✓

    The query returns an error.

    Why this is correct

    MongoDB forbids mixing inclusion and exclusion in a single projection, as it creates ambiguity about which fields should be returned. The database server will explicitly return an error when it detects this configuration, forcing the developer to choose a consistent projection strategy for the requested fields.

  • ✗

    The inclusion takes precedence over the exclusion.

    Why it's wrong here

    MongoDB does not prioritize one projection type over the other. Instead, it treats the presence of both as an invalid operation. If you need both, you must either only include the fields you need or only exclude the fields you do not want, unless you are specifically handling the _id.

  • ✗

    The exclusion takes precedence over the inclusion.

    Why it's wrong here

    There is no precedence order between inclusion and exclusion. The server rejects the query entirely because the logical state of the requested document is undefined. The developer must refactor the projection to use only one type, except for the special handling afforded to the _id field.

  • ✗

    It returns the intersection of both fields.

    Why it's wrong here

    The database engine does not attempt to calculate an intersection or union of the projection rules. It is a hard architectural constraint that prevents the query from executing. Providing a clean, consistent projection is a requirement for successful data retrieval in the MongoDB query language.

About these practice questions

One of 222 original C100DBA 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 C100DBA 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 C100DBA exam.