Which TWO of the following statements correctly describe the MongoDB document model?
Trap 1: Documents must have an identical set of fields within a collection.
MongoDB supports schema flexibility, meaning documents within the same collection can have different structures. Requiring identical fields would mimic a rigid relational table, which limits the ability to store polymorphic data and hinders the developer's ability to evolve the application schema over time as requirements change.
Trap 2: All documents are limited to a maximum size of 64MB.
MongoDB enforces a strict 16MB limit on the size of a single BSON document. This constraint ensures that the database maintains performance and prevents operations from consuming excessive memory. A 64MB limit is incorrect and does not align with the standard documented constraints of the database engine.
Trap 3: Joins are impossible to perform in MongoDB queries.
While the primary goal of the document model is to avoid joins through embedding, MongoDB supports the $lookup operator within the aggregation framework. This allows for left outer joins between collections when data relationships require normalization, providing flexibility for specific querying requirements that cannot be met by embedding.
- A
Documents must have an identical set of fields within a collection.
Why it fails: MongoDB supports schema flexibility, meaning documents within the same collection can have different structures. Requiring identical fields would mimic a rigid relational table, which limits the ability to store polymorphic data and hinders the developer's ability to evolve the application schema over time as requirements change.
- B
Documents can contain nested arrays and sub-documents.
The document model natively supports hierarchical data structures, including nested sub-documents and arrays. This allows developers to represent complex, real-world data models accurately within a single document, reducing the need for joins and simplifying the application code required to map data to objects.
- C
All documents are limited to a maximum size of 64MB.
Why it fails: MongoDB enforces a strict 16MB limit on the size of a single BSON document. This constraint ensures that the database maintains performance and prevents operations from consuming excessive memory. A 64MB limit is incorrect and does not align with the standard documented constraints of the database engine.
- D
The model allows for schema evolution without downtime.
The dynamic nature of the document model allows developers to add new fields to documents on the fly. Because the database does not require a pre-defined schema, applications can evolve their data structures without the need for destructive schema migrations or locking tables, supporting continuous deployment patterns.
- E
Joins are impossible to perform in MongoDB queries.
Why it fails: While the primary goal of the document model is to avoid joins through embedding, MongoDB supports the $lookup operator within the aggregation framework. This allows for left outer joins between collections when data relationships require normalization, providing flexibility for specific querying requirements that cannot be met by embedding.