
Most application data does not arrive as neat rows. An order carries its line items, a patient record carries visits and attachments, a product has attributes that differ by category, and all of them change shape as the product evolves. In a relational database each of those changes means a schema migration and a few more joins. MongoDB stores the data the way the application uses it, as documents, so the model can grow with the product and a whole object can be read or written in one operation.
This article explains what MongoDB is, how it stores and scales data, where it fits, where another database is the better choice, and how it compares with the alternatives.
What is MongoDB?
MongoDB is a document database, one of the NoSQL family. It stores records as BSON documents, a binary form of JSON, groups them into collections, and lets you query them with a rich query language and an aggregation pipeline. It runs on Linux, Windows and macOS, and is also offered as a managed cloud service, MongoDB Atlas, on AWS, Google Cloud and Microsoft Azure.
MongoDB was created at 10gen, a company founded in 2007 by Dwight Merriman, Eliot Horowitz and Kevin Ryan, who had worked together at DoubleClick. They started out building a cloud application platform and wrote a database for it; the database turned out to be the more useful product. 10gen released it as an open-source project in February 2009, the first version shipped in August 2009, and in 2013 the company renamed itself MongoDB, Inc. MongoDB Atlas followed in 2016.
On licensing, the details matter. Since 16 October 2018, new releases of MongoDB Community Server are published under the Server Side Public License (SSPL), which MongoDB created; earlier versions were under the AGPL. The SSPL lets you use, modify and run MongoDB in your own products, but a company offering MongoDB itself as a public service must release the source of its whole service stack. The Open Source Initiative has not approved the SSPL, so MongoDB is usually described as source-available rather than open source. The official drivers are under the Apache 2.0 licence, and MongoDB Enterprise Advanced and Atlas are commercial products.
How MongoDB works
Documents and collections. A document is a set of field and value pairs, where values can be nested documents and arrays. An order document can contain its customer snapshot and its line items, so reading the order is one lookup. Documents in a collection do not need identical fields, and when you want rules, JSON Schema validation can enforce them.
Indexes and queries. Queries filter, project and sort on any field, including fields inside arrays and nested documents. Indexes cover single fields, compound keys, arrays, text, geospatial data and time-to-live expiry. The aggregation pipeline chains stages such as $match, $group and $lookup to filter, reshape and join data on the server.
Replica sets for availability. A production deployment is a replica set: one primary that accepts writes and secondaries that copy its changes. If the primary fails, the members elect a new one automatically, usually within seconds.
Sharding for scale. When one replica set is no longer enough, a collection can be sharded: split across several replica sets by a shard key. Applications keep talking to the cluster as if it were one database, while reads and writes spread across machines.
Transactions when you need them. Single-document writes are atomic, and since version 4.0 MongoDB supports multi-document ACID transactions, extended to sharded clusters in 4.2. A well-designed document model needs them less often than a relational one, but they are there for operations that span several documents.
Key features
- Flexible schema with optional JSON Schema validation, so structure can be enforced where it matters.
- Aggregation pipeline for grouping, reshaping and joining data inside the database.
- Replication and automatic failover through replica sets.
- Horizontal scaling through sharding.
- Change streams that let applications react to inserts, updates and deletes as they happen.
- Time series collections for sensor, metrics and event data.
- Queryable Encryption, which lets the server run certain queries on data it cannot decrypt.
- MongoDB Atlas, the managed service, with built-in full-text search and vector search for AI features.
- Official drivers for languages such as C#, Java, Python, Node.js, Go and PHP.
Where MongoDB is used
- SaaS products whose data model keeps changing as features are added.
- Catalogues and content, where items in the same collection have different attributes.
- User profiles, sessions and personalisation data read as a whole per user.
- IoT and event data, using time series collections.
- AI features, where documents, metadata and vector embeddings can live in the same database.
When to choose MongoDB, and when not to
Choose MongoDB when:
- The data is naturally hierarchical and usually read and written as whole objects.
- The model will change often, and you want to ship features without a migration for each one.
- You expect to scale out across several machines, or want high availability built in from the start.
- Your stack is JSON-centred, from a Node.js or .NET API to the front end.
Look elsewhere when:
- The data is deeply relational, with many-to-many relationships, heavy joins and ad-hoc reporting at the core of the product. A relational database such as PostgreSQL fits that shape better.
- You need a fast cache or session store. Redis is built for that.
- You plan to offer a database service to third parties, or your policy requires an OSI-approved licence. Read the SSPL terms first.
MongoDB's weak spots are mostly about modelling. A document model designed like a set of relational tables gets the costs of both approaches, and a poorly chosen shard key is hard to change later. Both are design decisions worth making early and deliberately.
MongoDB and its alternatives
| Database | Model | Licence and hosting | Best fit |
|---|---|---|---|
| MongoDB | Documents (BSON) | SSPL Community, commercial Enterprise, managed Atlas | Evolving models, document-shaped data, scale-out |
| PostgreSQL | Relational, with JSONB | Open source, every cloud | Relational data, complex queries and reporting |
| Amazon DynamoDB | Key-value and documents | Managed, AWS only | Very high-scale access patterns on AWS |
| Azure Cosmos DB | Multi-model, MongoDB-compatible API | Managed, Azure only | Global apps on Azure |
| Cloud Firestore | Documents, real-time sync | Managed, Google Cloud | Mobile apps with offline and live updates |
| RavenDB | Documents, ACID by default | AGPL and commercial | .NET teams wanting built-in indexing and search |
The question we hear most is MongoDB or PostgreSQL, and it deserves more than a table row. We answer it in a separate article: MongoDB vs Postgres: why we have recommended MongoDB for a decade.
Among document databases, Amazon DynamoDB and Azure Cosmos DB tie you to one cloud in exchange for a fully managed service, Cloud Firestore trades query power for real-time sync to mobile clients, and RavenDB is a smaller, .NET-centred option.
How we use MongoDB at Internative
MongoDB is our default for new projects, and the article linked above explains the reasoning. We choose it for projects that need schema flexibility, rapid iteration and horizontal scalability: it lets us build data-driven products that keep evolving without adding operational complexity.
Three of our published customer stories run on it:
- Nevados, a platform that builds audit workpapers straight from the trial balance, uses MongoDB with .NET and Python, a Next.js and React front end, and a self-hosted LLM.
- RiskConnect, the EHS, 5S and Kaizen field engagement platform for Küçükoğlu Holding, combines MongoDB with .NET, Hangfire, Vue.js and a Flutter field app.
- Elra Health, a digital healthcare platform, runs MongoDB and Redis behind .NET, Node.js, Vue.js, Flutter and WebRTC on AWS.
If you are building a SaaS product or a business platform and want a data model that can keep up with it, our SaaS design and development team can help you design it.
Frequently asked questions
What type of database is MongoDB?
MongoDB is a NoSQL document database. It stores data as JSON-like documents in collections instead of rows in tables, supports indexes, aggregation and multi-document transactions, and scales horizontally through sharding. For the wider picture, see What is NoSQL? What are the benefits of using NoSQL?
Who created MongoDB?
MongoDB was created at 10gen, the company Dwight Merriman, Eliot Horowitz and Kevin Ryan founded in 2007. The database was released as open source in 2009, and 10gen renamed itself MongoDB, Inc. in 2013.
Is MongoDB free?
MongoDB Community Server is free to download and use, including in commercial applications, under the SSPL. MongoDB Atlas has a free tier for small clusters, and paid tiers for production. MongoDB Enterprise Advanced is a commercial edition with extra security and management tooling.
Is MongoDB open source?
Not by the Open Source Initiative's definition. Since October 2018 the server has been licensed under the SSPL, which the OSI has not approved, so it is usually called source-available. The source code is public and versions released before the change remain under the AGPL. The official drivers use the Apache 2.0 licence.
Keep reading
The articles that follow this one.



