MongoDB

MongoDB Design Philosophy

MongoDB wasn’t designed in a lab. We built MongoDB from our own experiences building large scale, high availability, robust systems. We didn’t start from scratch, we really tried to figure out what was broken, and tackle that. So the way I think about MongoDB is that if you take MySql, and change the data model from relational to document based, you get a lot of great features: embedded docs for speed, manageability, agile development with schema-less databases, easier horizontal scalability because joins aren’t as important. There are lots of things that work great in relational databases: indexes, dynamic queries and updates to name a few, and we haven’t changed much there. For example, the way you design your indexes in MongoDB should be exactly the way you do it in MySql or Oracle, you just have the option of indexing an embedded field.
—Eliot Horowitz, MongoDB CTO and Co-founder

What is MongoDB?

MongoDB (from "humongous") is an open-source document database, and the leading NoSQL database. Written in C++, It is a cross-platform document-oriented database. Classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster. Released under a combination of the GNU Affero General Public License and the Apache License, MongoDB is free and open-source software.

What are MongoDB features:

  • Document-Oriented Storage: JSON-style documents with dynamic schemas offer simplicity and power.
  • Full Index Support: Index on any attribute, just like you're used to.
  • Replication & High Availability: Mirror across LANs and WANs for scale and peace of mind.
  • Auto-Sharding: Scale horizontally without compromising functionality.
  • Querying: Rich, document-based queries.
  • Fast In-Place Updates: Atomic modifiers for contention-free performance.
  • Map/Reduce: Flexible aggregation and data processing.
  • GridFS: Store files of any size without complicating your stack.
  • MongoDB Management Service (MMS) : Manage MongoDB on the cloud infrastructure of your choice.
  • MongoDB Enterprise: The best way to run MongoDB in production. Secured. Supported. Certified.

MongoDB Data Model

A MongoDB deployment hosts a number of databases. A database holds a set of collections. collection holds a set of documents. document is a set of key-value pairs. Documents have dynamic schema. Dynamic schema means that documents in the same collection do not need to have the same set of fields or structure, and common fields in a collection’s documents may hold different types of data.

RDBMS vs MongoDB

RDBMSMongoDB
Tuple/RowCollection
ColumnField
Table JoinEmbedded Documents or Reference documents
Primary KeyPrimary Key (Default key _id provided by mongodb itself)
Database Server and Client
Mysqld/Oraclemongod
mysql/sqlplusmongo