MongoDB NoSQL Interview Master
100+ MongoDB questions covering Aggregation Framework, Compound Indexes, Sharding, Replica Sets, WiredTiger engine, and Document Schema Design.
Difficulty Filters
Tools & Options
What is MongoDB?
MongoDB is an open-source, document-oriented NoSQL database program. Instead of using tables and rows as in traditional relational databases, MongoDB uses JSON-like documents with optional schemas (BSON). It is designed for scalability, high performance, and high availability.
What is a Document in MongoDB?
A document is the basic unit of data in MongoDB, analogous to a row in an RDBMS. Documents are composed of field-and-value pairs and are stored in BSON (Binary JSON) format.
{
"name": "John Doe",
"age": 30,
"interests": ["coding", "reading"]
}What is a Collection in MongoDB?
A collection is a grouping of MongoDB documents. It is equivalent to a table in a relational database. Collections do not enforce a strict schema, although schema validation is possible.
What is BSON?
What are the primary advantages of MongoDB?
What is the '_id' field in MongoDB?
What is an ObjectId in MongoDB?
How do you create a database in MongoDB?
How do you insert a document into a collection?
How do you find all documents in a collection?
What is the difference between MongoDB and RDBMS?
What is Namespace in MongoDB?
How do you update a document in MongoDB?
How do you delete a document?
What is the purpose of the '$set' operator?
What is the difference between findOne() and find()?
How do you limit the number of results in MongoDB?
How do you sort results in MongoDB?
What is Projection in MongoDB?
What is the use of the '$in' operator?
How do you count the number of documents in a collection?
What is an Index in MongoDB?
What is a GridFS?
What is the default port for MongoDB?
What is the command to see all databases?
How do you perform a simple count in MongoDB?
What is an Aggregation Pipeline in MongoDB?
Explain the '$match' stage in Aggregation.
Explain the '$group' stage in Aggregation.
What is the difference between Embedding and Referencing in Schema Design?
What is a TTL (Time-To-Live) Index?
What is a Capped Collection?
What is the use of the '$lookup' operator?
How do you handle Transactions in MongoDB?
What are Covered Queries?
Explain the Concept of Sharding.
What is a Shard Key?
What is a Replica Set?
What is a Write Concern in MongoDB?
What is a Read Preference?
What is the purpose of the '$unwind' stage?
Explain the '$facet' stage in aggregation.
What is the difference between '$addFields' and '$project'?
What is a Compound Index?
What is a Partial Index?
How do you view index usage in MongoDB?
What is the 'oplog' (Operations Log)?
What is an Arbiter in a Replica Set?
How to backup and restore MongoDB databases?
What is the use of the '$out' stage in aggregation?
Explain the difference between 2d and 2dsphere indexes.
How does MongoDB handle data consistency?
What is Joins in MongoDB?
Explain the Working of 'Election' in Replica Sets.
What are Change Streams?
Explain the use of 'Hint' in MongoDB.
What is the 'wiredTiger' storage engine?
What are Orphaned Documents?
What is the 'Journal' in MongoDB?
Explain the 'Working Set' concept.
What is a Sparse Index?
Explain 'Mongoose' in the context of MongoDB.
What is the 16MB Document Limit?
Explain 'Horizontal' vs 'Vertical' Scaling.
What is 'Read Concern' in MongoDB?
Explain 'Map-Reduce' in MongoDB.
What are 'Views' in MongoDB?
What is 'Causal Consistency'?
How to tune MongoDB performance?
What is 'Write Strategy' for Sharding?
Explain 'Balancing' in Sharded Clusters.
What are 'Sessions' in MongoDB?
How to monitor MongoDB?
What is 'Schema Validation'?
Explain 'Disk Compression' in WiredTiger.
Scenario: How to find top 5 most expensive orders using aggregation?
Scenario: How to calculate total revenue per category?
Scenario: How to find users who have exactly 3 tags?
Scenario: How to remove a field from all documents in a collection?
Scenario: How to find documents where an array field contains a specific value?
Scenario: How to perform a 'Full Text Search' for the word 'database'?
Scenario: How to find documents with a field that is NOT null and exists?
Scenario: How to increment a counter field by 1?
Scenario: How to find documents where field A is greater than field B?
Scenario: How to rename a field across all documents?
Scenario: How to push an item to an array only if it doesn't already exist?
Scenario: How to get the current date in an aggregation pipeline?
Scenario: How to find documents that were created in the last 24 hours?
Scenario: How to 'Join' users with their posts using aggregation?
Scenario: How to filter a 'joined' array from $lookup?
Scenario: How to flatten an array of objects into separate documents?
Scenario: How to find the average age of users per city, but only for cities with more than 10 users?
Scenario: How to update multiple fields in a single document based on conditions?
Scenario: How to pull (remove) all occurrences of 'error' from an array?
Scenario: How to find documents where a field is of a specific type (e.g., String)?
Scenario: How to perform a 'Dry Run' of a deletion?
Scenario: How to get the last 10 log entries?
Scenario: How to search for coordinates within a 5km radius of a point?
Scenario: You need a schema where one document contains 'many' others, potentially causing size issues. Solution?
How to export a collection to a JSON file?
Technical Interview Mastery Blueprint
Proven methodologies and frameworks to succeed in technical and architecture rounds.
1. The Engineering STAR Technique
When responding to architectural or situational questions, structure your answer using Situation, Technical Constraint, Action, and Measurable Result. Rather than jumping straight to syntax, articulate the business problem, why certain patterns (e.g. caching, queuing, immutability) were selected over alternatives, and what latency or throughput improvements were achieved.
2. Defending Architectural Trade-Offs
Senior interviewers evaluate how you weigh trade-offs. Always explain why you chose an approach: e.g., memory overhead vs CPU cycle speed, consistency vs availability (CAP theorem), or normalized schemas vs denormalized fast reads. Stating the drawbacks of your own proposal demonstrates maturity and production experience.
3. Clean Code & Edge-Case Proactivity
In live-coding rounds, communicate your thinking aloud before typing. State edge cases explicitly: null or undefined inputs, extreme boundary values, concurrency races, and network timeouts. Writing modular, well-named functions with deterministic unit tests separates junior candidates from staff-level engineers.
4. Antipatterns to Avoid
Avoid reciting memorized definitions without practical context. Never dismiss non-functional requirements such as security (CSRF, injection, token rotation), observability (logging, metrics), and accessibility (ARIA, semantic standards). Always ask clarifying scope questions before writing complex implementations.
Explore Related Tools
Hand-picked utilities and calculators related to this tool.