Practice & Assessment
Test your understanding of MongoDB Foundations
Multiple Choice Questions
5What is the maximum size of a single MongoDB document?
Which component of an ObjectId encodes the document's creation time?
In MongoDB schema design, when should you prefer embedding over referencing?
What does BSON add over standard JSON?
When you run 'use newDB' in mongosh and then exit without inserting any documents, what happens?
Coding Challenges
1Design a Schema for a Blog Platform
Given a blog platform with users, posts, and comments: design two MongoDB schemas — one fully embedded and one fully referenced. Write the document structure as JavaScript objects (no live DB needed). Then write a 3-sentence justification for which schema you would use in production and why. Your output must show both schemas and the justification. Constraints: posts can have up to 500 comments, a user can have thousands of posts. Estimated time: 20 minutes.
Mini Project
Local MongoDB Explorer CLI
Build a Node.js CLI script that connects to a local MongoDB instance, lists all databases, lets the user pick one interactively, then lists its collections and prints the first 3 documents from a chosen collection in formatted JSON. Use the official mongodb npm driver (no Mongoose). The script must handle connection errors gracefully and close the connection on exit. Concepts used: connection strings, mongosh equivalents in code, BSON document output, collection introspection.
