MongoDB Introduction

MongoDB is a NoSQL database that stores data as flexible documents (JSON-like) instead of rigid tables and rows. It's a natural fit for JavaScript apps and evolving data.

Documents and collections

Documents live in collections. Unlike SQL tables, documents in one collection don't have to share the same fields β€” so your data shape can grow and vary without migrations.

documents
{ "name": "Asha", "email": "asha@x.com", "roles": ["admin"] }
{ "name": "Ravi", "phone": "555-0100" }   // different fields, same collection

SQL vs MongoDB terms

SQL termMongoDB term
TableCollection
RowDocument
ColumnField
JOIN$lookup / embedding

When MongoDB fits

  • Flexible or rapidly-changing schemas.
  • Naturally nested/hierarchical data (a document = one object).
  • High write throughput and easy horizontal scaling (sharding).
  • For highly relational data with complex joins and strict integrity, a SQL database (PostgreSQL) is often a better fit.
Note: This course reflects MongoDB 8, using the modern mongosh shell. MongoDB stores documents as BSON (binary JSON) β€” so it supports richer types like dates and binary data, not just plain JSON.
Free preview. Sign in and subscribe to unlock all 809 lessons across 25 courses.
MongoDB Introduction β€” MongoDB | Full Stack Learning Simplified