MongoDB vs RDBMS — MongoDB Technical Interview Questions & Answers
Documents/collections vs rows/tables terminology mapping.
MongoDB vs RDBMS
- Simple meaning: RDBMS (MySQL) uses tables and SQL joins. MongoDB uses documents and usually embeds related data.
- Vocabulary: table ≈ collection, row ≈ document, column ≈ field, JOIN ≈ embed or $lookup.
- How to choose: fees + attendance with foreign keys → MySQL. Product with varying fields, nested comments → MongoDB.
- Try this: same student in SQL as columns; in Mongo as one document with marks: [72, 40].
- Common mistake: “Mongo has no joins.” $lookup exists, but embed is the usual design.
- Interview tip: Pick one use case for each. Do not say one is always better.
Technical Interview Tip: Table=collection, row=document. Strict money → SQL. Flexible docs → Mongo.
Code Examples for MongoDB vs RDBMS
MongoDB vs RDBMS — working example
// Collection "users" holds BSON documents (JSON-like):
db.users.insertOne({
name: "Ada",
email: "ada@example.com",
age: 36,
skills: ["Java", "MongoDB"],
address: { city: "Pune", pin: "411001" }
})
db.users.find({ "address.city": "Pune" })MongoDB vs RDBMS — mongoDB stores BSON documents in collections — flexible schema, nested fields, rich queries.
How to Explain MongoDB vs RDBMS to an Interviewer
When MySQL instead of Mongo?
Fixed schema, foreign keys, many joins Fees / marks sheets