What is MongoDB? — MongoDB Technical Interview Questions & Answers
A document-oriented NoSQL database storing JSON-like BSON documents.
What is MongoDB?
- Simple meaning: MongoDB is a NoSQL database. It stores data as documents (like a JSON object), not as rows in a table.
- Picture: one student is one document: { name: "Asha", roll: 12, marks: 72 }. Many students live in a collection called students. Collections live in a database called college.
- How to start (10 minutes): 1) Install MongoDB Community or create a free Atlas cluster. 2) Open mongosh (or Compass). 3) Run: use college then insert one student then db.students.find().
- SQL map: database → database, table → collection, row → document, column → field. Primary key is _id (Mongo makes it if you skip it).
- When to use it: notes, product catalogs, logs, profiles — data whose shape can change. Prefer MySQL/Postgres when you need strict tables, foreign keys, and lots of joins (fees, marks sheets).
- Common mistake: treating MongoDB like “SQL with no rules”. You still design embed vs reference. Another trap: opening a .js file in the browser — mongosh talks to the database, not Chrome.
- Interview tip: “Document database. Collection of BSON documents. Flexible fields. Query with find({ roll: 12 }).”
college (database)
│
▼
students (collection)
│
▼
{ name, roll, marks }Technical Interview Tip: Say document + collection + _id + one find example.
Code Examples for What is MongoDB?
What is MongoDB? — working example
// What is MongoDB?
db.users.find({ active: true }).sort({ name: 1 }).limit(5)What is MongoDB?: find active users, sort by name, limit 5.
How to Explain What is MongoDB? to an Interviewer
What is MongoDB?
A document (NoSQL) database Stores JSON-like BSON documents in collections
How do you try it first?
Install Community or Atlas mongosh: use college, insertOne, find()