All academies
Roadmap
LEVEL 1 · INTRODUCTION

What is MongoDB?

8 min read

MongoDB is a document database. Instead of storing data in rows and columns like a relational database, it stores data as flexible, JSON-like documents called BSON (Binary JSON). Related data lives together in a single document, so what your application reads and writes maps directly to what the database stores.

Documents, Collections, Databases

A document is a set of key-value pairs. Documents live inside collections (roughly, tables without a fixed schema), and collections live inside databases. One MongoDB deployment can host many databases.

A typical document
{
  _id: ObjectId("64f1a2..."),
  name: "Wireless Mouse",
  price: 29.99,
  tags: ["wireless", "accessories"],
  supplier: { name: "TechCorp", country: "DE" }
}

Why developers choose MongoDB

1. Flexible schema — documents in the same collection can have different fields, so you can evolve your model without migrations.

2. Rich queries — filters, aggregations, text search, and geospatial queries.

3. Horizontal scaling — sharding distributes data across machines.

4. High availability — replica sets keep copies of your data and fail over automatically.

SQL vs MongoDB terminology

Table → Collection. Row → Document. Column → Field. JOIN → $lookup (or embedding). Primary key → _id.

Try it yourself

db.products.findOne()
Run in Shell

Check your understanding

Q1.

What format does MongoDB use to store documents internally?

Q2.

Every document in a MongoDB collection must have exactly the same fields.

Q3.

Which SQL concept is closest to a MongoDB collection?