Challenge - 5 Problems
Document Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding document structure vs row structure
In MongoDB, which statement best describes how data is stored compared to a traditional SQL row?
Attempts:
2 left
💡 Hint
Think about how JSON-like documents allow more flexible data than rows.
✗ Incorrect
MongoDB stores data as documents that can have nested objects and arrays, allowing flexible schemas. SQL rows have fixed columns.
❓ query_result
intermediate2:00remaining
Query result shape in MongoDB vs SQL
Given a MongoDB collection 'users' with documents containing nested 'address' objects, what will this query return?
`db.users.find({"address.city": "Seattle"})`
MongoDB
db.users.find({"address.city": "Seattle"})Attempts:
2 left
💡 Hint
MongoDB allows querying nested fields using dot notation.
✗ Incorrect
The query returns full user documents where the nested 'address.city' equals 'Seattle'.
📝 Syntax
advanced2:00remaining
Correct MongoDB query to update nested document field
Which of the following MongoDB update queries correctly sets the 'address.zip' field to '98101' for user with _id 123?
Attempts:
2 left
💡 Hint
Use dot notation inside $set to update nested fields.
✗ Incorrect
Option C uses correct syntax with $set and dot notation to update nested field 'address.zip'.
❓ optimization
advanced2:00remaining
Optimizing queries on nested document fields
You have a large MongoDB collection with documents containing nested 'profile.age' fields. Which indexing strategy will best optimize queries filtering by 'profile.age'?
Attempts:
2 left
💡 Hint
Indexes on nested fields use dot notation.
✗ Incorrect
MongoDB supports indexes on nested fields using dot notation, so indexing 'profile.age' improves query speed.
🔧 Debug
expert3:00remaining
Diagnosing unexpected query results with nested documents
A developer runs this query on a MongoDB collection:
`db.orders.find({"customer.address.city": "Boston"})`
But it returns no results, even though some documents have 'customer' with nested 'address.city' equal to 'Boston'. What is the most likely cause?
Attempts:
2 left
💡 Hint
Consider how nested arrays affect dot notation queries.
✗ Incorrect
If 'customer' is an array, dot notation alone won't match nested fields inside array elements. Use $elemMatch to query inside arrays.