0
0
MongoDBquery~20 mins

Document size limits and structure rules in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
MongoDB Document Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
What is the maximum size of a single MongoDB document?
MongoDB has a limit on how large a single document can be. What is the maximum size allowed for one document?
A1 gigabyte (GB)
B64 megabytes (MB)
C16 megabytes (MB)
D256 kilobytes (KB)
Attempts:
2 left
💡 Hint
Think about the BSON document size limit.
query_result
intermediate
1:30remaining
What happens if you try to insert a document larger than the limit?
You try to insert a document with size 20 MB into a MongoDB collection. What will be the result?
AThe insert operation fails with an error about document size.
BThe document is automatically split into smaller documents.
CThe document is truncated to 16 MB and inserted.
DThe insert succeeds without any error.
Attempts:
2 left
💡 Hint
MongoDB enforces strict size limits on documents.
📝 Syntax
advanced
2:00remaining
Which document structure violates MongoDB rules?
Consider these four MongoDB documents. Which one violates MongoDB's document structure rules?
A{ "name": "Carol", "age": 27, "address": { "street": "Main St", "city": "Town" } }
B{ "name": "Bob", "age": 25, "$invalidField": "value" }
C{ "name": "Alice", "age": 30, "_id": ObjectId("507f1f77bcf86cd799439011") }
D{ "name": "Dave", "age": 22, "hobbies": ["reading", "sports"] }
Attempts:
2 left
💡 Hint
Field names starting with $ are reserved in MongoDB.
optimization
advanced
2:00remaining
How to store large files exceeding document size limit in MongoDB?
You need to store files larger than 16 MB in MongoDB. Which approach is correct?
AUse GridFS to split and store files in chunks.
BCompress the file and store it as a string in one document.
CStore the entire file as a single document with a large binary field.
DSplit the file manually into multiple documents without using any special feature.
Attempts:
2 left
💡 Hint
MongoDB provides a special specification for large files.
🔧 Debug
expert
2:30remaining
Why does this MongoDB insert fail with a 'BSONObjectTooLarge' error?
You run this insert command:
db.collection.insertOne({ "data": new Array(17000000).fill(0) })

It fails with a 'BSONObjectTooLarge' error. Why?
AThe 'fill' method is not supported in MongoDB shell.
BMongoDB does not allow arrays as field values.
CThe insertOne method requires a smaller batch size parameter.
DThe array creates a document larger than 16 MB, exceeding the limit.
Attempts:
2 left
💡 Hint
Think about the size of the document created by the array.