Cloud & Software Development

MongoDB

Also known as: Mongo, MongoDB Atlas, BSON, document database

MongoDB is a NoSQL database where data is stored as documents (JSON-like objects) rather than rows in tables.

It's flexible (documents in the same collection can have different fields) making it popular for applications where data structures evolve quickly or vary per record.

MongoDB, explained at three levels

At home

A regular database stores data in rows and columns, like a spreadsheet. MongoDB stores data as documents (like JSON objects) so a product can have any fields you want without redesigning the database. It's more flexible but less structured.

At work

Teams choose MongoDB when their data doesn't fit neatly into tables: user profiles with varied fields, product catalogues with different attributes per category, or event logs with evolving schemas. Documents map naturally to the objects that application code works with.

Real-world examples

At home

Fatima built a recipe app using MongoDB because each recipe has a different structure: some have nutritional info, some have step images, some have video links. MongoDB lets her store whatever fields each recipe has without empty columns.

At work

Sophie's team uses MongoDB for their product catalogue (10 million products, each with different attributes depending on category) and PostgreSQL for orders and payments. The mixed approach uses each database where it fits best.

Common confusions

  • MongoDB is better than SQL databases — MongoDB and relational databases (PostgreSQL, MySQL) have different strengths. MongoDB fits flexible, document-shaped data with fast iteration. SQL databases are better for complex relationships, reporting, and strong consistency requirements. Neither is universally better.
  • MongoDB doesn't support transactions — MongoDB has supported multi-document ACID transactions since version 4.0 (2018). Earlier versions only had single-document atomicity, which gave MongoDB its reputation for lacking transactions, but this is no longer accurate.

For analysts

BAs can connect BI tools such as Tableau and Power BI to MongoDB Atlas through its SQL interface, so they can query MongoDB with SQL. Alternatively, MongoDB's aggregation pipeline can produce summary reports directly from the database.

History & origin

MongoDB was created in 2007 by Dwight Merriman, Eliot Horowitz, and Kevin Ryan, two of whom had co-founded DoubleClick, frustrated by the rigidity of relational databases for large-scale web applications. The name comes from 'humongous': reflecting its target for large datasets. MongoDB went public in 2017. It popularized the document-oriented NoSQL model and the term 'schemaless' database. Despite early criticisms about default settings allowing data loss, MongoDB matured significantly: adding multi-document ACID transactions in version 4.0 (2018).