MongoDB , 25 Interview Questions & Answers

Ayan22
  • Feb 08, 2026 ·
Ayan22

MongoDB 25 Interview Questions & Answers

1. What is MongoDB?

MongoDB is a NoSQL, document-oriented database that stores data in  JSON-like BSON documents, instead of tables and rows. 

2. What are the key features of MongoDB? 

  • Schema-less 
  • High performance 
  • Horizontal scalability 
  • Indexing support 
  • Replication & sharding 
  • Rich query language

3. What is a document in MongoDB?

A document is a single record stored in BSON format (binary JSON). 

Example: `'json { "_id": 1, "name": "Ayan", "age": 25 } '

4. What is a collection?

A collection is a group of documents, similar to a table in relational databases

5. Difference between MongoDB and MySQL

MongoDB      

  •  NoSQL 
  • Document-based 
  • Schema-less 
  • Horizontal scaling

MySQL 

  • Relational               
  • Table-based          
  •  Fixed schema        
  • Vertical scaling     

6. What is BSON ?

 BSON stands for Binary JSON. It is optimized for fast storage and traversal. 

7. What is `_id` in MongoDB?

 `_id` is a 'unique identifier' automatically generated for every document. It acts as the primary key. 

 8. What are indexes in MongoDB?

Indexes improve query performance by reducing the number of documents scanned. 

9. Types of indexes in MongoDB

  • Single Field Index 
  • Compound Index 
  • Multikey Index 
  • Text Index 
  •  Geospatial Index 
  •  Hashed Index 

 10. What is replication in MongoDB?

 Replication copies data across multiple servers to ensure high availability and fault tolerance. 

 11. What is a Replica Set?

A Replica Set is a group of MongoDB servers:  Primary handles writes and Secondary copies data. 

 12. What is sharding?

Sharding is horizontal data partitioning that distributes data across multiple servers for scalability. 

13. What is a shard key?

 A shard key determines how data is distributed across shards. Choosing the right key is critical for performance. 

14. What is Aggregation in MongoDB?

 Aggregation processes data and returns computed results (similar to SQL `GROUP BY`). 

 15. What is Aggregation Pipeline?

 A sequence of stages like: 'js $match → $group → $sort → $project '

16. What is '$lookup'?

' `$lookup' performs 'joins' between collections in MongoDB. 

 17. Difference between `find()` and `aggregate()`

find()

  •  Simple queries
  •  Faster 
  •  No grouping

aggregate()  

  •  Complex data processing 
  •  More powerful
  •  Supports grouping


18. What is denormalization in MongoDB?

 Denormalization means embedding related data in one document to reduce joins and improve performance. 

 19. What is a capped collection?

 A fixed-size collection that automatically overwrites old documents when the limit is reached. 

 20. What is GridFS?

'GridFS' stores large files (>16MB) by splitting them into chunks.

 21. What is atomicity in MongoDB?

Operations are atomic at the document level

22. What are transactions in MongoDB?

Transactions allow multiple operations to be executed as a single unit (ACID compliant). 

23. What is `mongod` and `mongo`?

'mongod' → MongoDB server * 'mongo' → MongoDB shell (client)

24. What is 'ObjectId`?

 A 12-byte unique identifier containing timestamp, machine id, process id, and counter. 

25. How does MongoDB handle schema changes?

 MongoDB is schema-less, so fields can be added or removed without altering existing documents.  


By : Ayan Banerjee


Recommended Articles