Beyond relational
The first decade of the 2000s saw consolidation of open source relational databases — MySQL and PostgreSQL as dominant choices — alongside growing unease with the relational model for emerging scenarios: web applications with rapidly evolving schemas, social networks with graph structures, analytics on heterogeneous datasets, IoT with semi-structured streams.
The term NoSQL — re-emerged in 2009 at a San Francisco meetup — identifies a family of alternative approaches: key-value stores (Riak, Voldemort, Dynamo), column families (Cassandra, HBase), graph databases (Neo4j), document stores. Among document stores, MongoDB is the first to reach widely used production.
MongoDB 1.0 was released on 11 August 2009 by 10gen (Eliot Horowitz, Dwight Merriman, Kevin Ryan), a company founded in 2007 initially to build a PaaS platform, later pivoted to just the database.
The data model
MongoDB stores documents — the fundamental unit, analogous to JSON objects — grouped in collections within databases. No predefined schema: documents in the same collection can have different fields.
The serialisation format is BSON (Binary JSON), a binary extension of JSON with additional data types (ObjectId, Date, Binary, Regex, Int32/64, Decimal128).
A typical document:
{
"_id": ObjectId("4f7d3e8b..."),
"name": "Mario Rossi",
"age": 52,
"addresses": [
{ "type": "home", "city": "Pisa" },
{ "type": "work", "city": "Florence" }
],
"tags": ["premium-customer", "subscriber"]
}
CRUD operations:
db.customers.insert(doc)— insertdb.customers.find({tags: "premium-customer"})— query with MongoDB-specific filtersdb.customers.update({_id: ...}, {$set: {...}})— update with atomic operatorsdb.customers.remove({...})— delete
The JavaScript shell
MongoDB exposes an interactive JavaScript V8-based shell (Mongo Shell). Queries are literally JavaScript; complex operations (aggregations, map-reduce) are written as JS functions executed server-side. This choice is natural for web developers already familiar with JS and will make MongoDB particularly popular in the Node.js ecosystem (emerging in parallel, 2009).
Indexes, query optimiser, concurrency
MongoDB 1.0 supports:
- Indexes — B-tree on single or compound fields, with unique constraints
- Query optimiser — picks the best index, with manual hint possible
- Database-granularity locks (global in 1.0, improving to collection-level in 2.x, document-level in 3.x with WiredTiger)
- Transactions limited to single document (multi-document will arrive in 4.0, 2018)
The lack of multi-document ACID transactions is an explicit trade-off: MongoDB prioritises horizontal scale and speed over complex transaction atomicity. A friction point with traditional finance/accounting applications; acceptable — or manageable — in web, analytics, logging applications.
Replication and sharding
MongoDB 1.0 already supports:
- Master/Slave replication (later replica set with automatic failover in 1.6)
- Horizontal sharding (in preparation for 1.6, September 2010)
- Server-side map-reduce for aggregations
Declared ambition: scale to many nodes without rewriting the application. The promise will prove partially true: MongoDB sharding is sophisticated but requires careful shard key design.
AGPL 3.0 licence and controversies
The choice to distribute the MongoDB server under GNU AGPL 3.0 — Affero GPL — has been controversial. AGPL extends GPL’s copyleft to the “use over a network” case: a SaaS service exposing modified MongoDB should make the code available. In 2009 AGPL is less accepted than Apache 2.0 or MIT in enterprise environments, many CIOs have reservations.
10gen responds with:
- Client drivers distributed under Apache 2.0 — applications using MongoDB are not “contaminated”
- MongoDB Enterprise — commercial subscription with QA, support, auditing
- Later (2018), move to SSPL (Server Side Public License) — another controversial licence, not recognised as open source by OSI, motivated by cloud providers offering MongoDB-as-a-service without contributing
Drivers and integration
At 1.0 release MongoDB has drivers for:
- Python — PyMongo, mature
- Ruby — for Ruby on Rails
- PHP — official driver
- Java — for enterprise applications
- C#/.NET — community driver
The Node.js driver will rapidly become one of the most used, fuelling the MEAN stack (MongoDB + Express + Angular + Node) in the early 2010s.
Adoption
As of 2009-2010 MongoDB is adopted by:
- Craigslist — classified archive
- Foursquare — social check-in
- bit.ly — URL shortener
- The New York Times — form data management
- SourceForge — migration from MySQL
Typical applications: content management, product catalogues, user sessions, logging, user-generated content, IoT data.
In the Italian context
As of 2009 Italian MongoDB adoption is limited to:
- Startups and web agencies exploring non-relational stacks
- Universities — NoSQL research projects
- Some publishing sites — content management
Adoption will grow in 2011-2013 alongside the NoSQL paradigm boom.
Historical role
MongoDB 1.0 democratises the NoSQL approach: with a mongodb:// connection string and a driver installed in minutes, a developer can build an application with document storage without SQL schema ceremony. It is not technically the first document store (Lotus Notes, CouchDB precede it), but is the one reaching critical adoption mass first, de facto defining the “modern” NoSQL pattern. Databases emerging later — notably the relaunch of PostgreSQL with JSONB in 2014 — will respond to the MongoDB model by assimilating some of its ideas.
References: MongoDB 1.0 (11 August 2009), 10gen Inc. (later MongoDB Inc.). Eliot Horowitz, Dwight Merriman, Kevin Ryan. AGPL 3.0 (server), Apache 2.0 (driver) licences. BSON format. JavaScript V8-based shell.
