# MongoDB

> A database that stores each record as a flexible JSON-like document, not a table row.

- Level: Intermediate
- Topics: Data, Software
- URL: https://tidbit.legios.com.ar/mongodb/
- In Spanish: [MongoDB](https://tidbit.legios.com.ar/es/mongodb/)

**MongoDB** is the best-known document database, a kind of NoSQL database. Instead of rows in tables with fixed columns, it stores **documents**: records that look like JSON, with fields, lists and nested objects. Similar documents live together in a **collection**, roughly what a table is in SQL.

The appeal is flexibility. A product in an online shop can be one document with its name, price, a list of sizes and an embedded set of reviews, all read in one go. Two documents in the same collection do not need the same fields, so adding a new attribute does not require changing a schema first. Under the hood it stores a binary form of JSON called BSON, and you query it with its own API rather than SQL.

It was first released in 2009 by the company now called MongoDB Inc., and the name comes from "humongous". Since 2018 it is licensed under the SSPL, which the company wrote and which many open-source groups do not consider open source. Most teams today use it through **MongoDB Atlas**, the company's managed cloud service. Over the years it added features once typical of relational databases, such as multi-document transactions.

## An analogy

Like a folder of index cards where each card can have whatever notes it needs, instead of a printed form where every box is fixed in advance.

## Keep in mind

- Stores JSON-like documents grouped in collections, not rows in tables.
- Documents in one collection can have different fields.
- Queried with its own API, not SQL; Atlas is the managed cloud version.
- Licensed under the SSPL since 2018, not a classic open-source license.

## Go deeper

- [What is MongoDB? (official docs)](https://www.mongodb.com/docs/manual/)
- [MongoDB on Wikipedia](https://en.wikipedia.org/wiki/MongoDB)

## Related terms

- [NoSQL](https://tidbit.legios.com.ar/nosql/): Databases that store data in shapes other than tables with fixed columns.
- [JSON](https://tidbit.legios.com.ar/json/): The plain-text format programs use to hand each other structured data.
- [SQL](https://tidbit.legios.com.ar/sql/): The language you use to ask a database questions.
- [Database schema](https://tidbit.legios.com.ar/database-schema/): The blueprint of a database: which tables exist, their columns and how they connect.
- [API](https://tidbit.legios.com.ar/api/): The menu of things one program lets another program ask for.
- [Open source](https://tidbit.legios.com.ar/open-source/): Software whose code anyone can read, use, change and share.
- [Cloud computing](https://tidbit.legios.com.ar/cloud-computing/): Renting computers over the internet instead of buying your own.
- [Database](https://tidbit.legios.com.ar/database/): An organized store of data that programs can search and update safely.
