Mongodb Certified Developer Associate C100dev · Free Practice Question Medium

Question 36

You're developing a microservice that needs to retrieve data from a MongoDB database. The data consists of a series of nested documents and arrays. One of the most frequent operations you'll be performing is retrieving a specific subdocument from a document. Given the considerations for efficient querying, which of the following strategies should you implement?

  • A

    Using the dot notation to query nested documents.

  • B

    Using the $elemMatch operator.

  • C

    Storing frequently accessed subdocuments as separate documents and linking them with references.

  • D

    Using the $in operator for nested array elements.

Reveal correct answer

Correct answer: C

A.

While dot notation allows you to access fields in nested documents, it does not inherently optimize the process of fetching specific subdocuments within complex, nested structures.

B.

While the $elemMatch operator is a powerful tool for querying array elements, it doesn't necessarily optimize the retrieval of specific subdocuments within complex, nested structures.

C.

When dealing with complex, nested structures, it is often more efficient to store frequently accessed subdocuments as separate documents and link them with references. This strategy can reduce the amount of data fetched in each query and can lead to improved query performance.

D.

The $in operator is used to filter documents where the value of a field equals any value in the specified array. It doesn't optimize the retrieval of nested documents.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need