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.
{
_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.