Introduction
MongoDB
MongoDB is a document-based, open-source database. MongoDB is a leading NoSQL database. It provides high performance, high availability, auto sharding, and automatic scaling. MongoDB database is written mainly in C++. Its drivers and client libraries are typically written in their respective languages, although some drivers use C extensions for better performance. MongoDB differs from relational databases because it is a schema-less database. Such databases usually have lower transaction safety but are faster in accessing data and scale compared to relational databases.
History of MongoDB
MongoDB was developed in October 2007 by a New York-based organization, 10gen, now called MongoDB Inc. It is written in C, C++, and JavaScript. MongoDB was initially developed as a Platform as a Service (PAAS). In 2009 MongoDB was introduced as an open-source database server. MongoDB provides backend services to many websites and to other services. For example, eBay, Foursquare, Viacom, Craigslist and the New York Times.
Document Database

MongoDB stores data as documents. So it is a document-based database. A document is a data structure that stores the data in field and value pairs. The format of MongoDB documents are similar to JavaScript Object Notation (JSON). The values of a field may include a simple value, array and other documents. MongoDB uses BSON format to store the data into a document.
The following are the advantages of a document type database:
- Documents written in JSON format is readable to humans, so it is easy to understand.
- We can generate embedded documents and arrays that reduce the need for Joins.
- Dynamic schema supports fluent polymorphism.
BSON
MongoDB represents JSON documents in a binary-encoded format called BSON behind the scenes. BSON extends the JSON model to provide additional data types and to be efficient for the encoding and decoding within various languages. It adds support for data types like date and binary that aren't supported in JSON.
The implementation of BSON in MongoDB has some benefits, for example:
- It's very fast in execution
- It's lightweight
- It's easy to traverse
- It supports embedding objects and arrays within other objects and arrays
- It provides support for Index and Object matching against query expressions
Transaction Management in MongoDB
MongoDB doesn't support multiple document transactions. It only provides atomic operations on a single document. These atomic operations are sufficient to handle the problem that requires transaction management.
Basic Translation Terms/Concepts:

- An RDBMS database is a set of tables, but in MongoDB, a database is a set of collections.
- Instead of a table, we use a collection in MongoDB.
- In an RDBMS, data is stored as rows, but MongoDB stores data as documents.
- Instead of columns, we use key-value pairs in MongoDB.
Key Features of MongoDB
MongoDB is a document type of database that uses JSON format for the data store.
The following are some key features of MongoDB.
- Dynamic Schema: MongoDB supports dynamic schemas. In other words, we need not define the schema before the insertion of data. We can change the schema of the database dynamically. A dynamic schema supports fluent polymorphism.
- Embedded Data Model: MongoDB uses an embedded data model. In other words, we can define a document as a key/value pair in another document.
- Use of Index: We can define an index on any attributes of a MongoDB records that increase the speed of data fetching.
- Rich Query: MongoDB supports rich queries to fetch data from the database.
- Automatic Scaling: MongoDB uses a Scaling Out approach. This is also known as Horizontal scaling. In the Scaling Out approach, data is distributed across clusters.
- Data Sharding: MongoDB spreads data across servers without affecting the performance of the application. It removes the dependency on a single server. The database never goes offline. In other words, it provides 24/7 x 365 services.
- Mirroring: We can set mirrors across a Local Area Network (LAN) and a Wide Area Network (WAN). That makes it easily scalable.
- Supports Many Language: MongoDB supports many languages including C, C++, Ruby, C#, Perl, PHP, Python, Java, JavaScript, Erlang, and Haskell.
- Replication: MongoDB supports data replication that has the data within a system geo-distributed, preferably using a non-interactive, reliable process.
- Dynamic Query: MongoDB supports dynamic query for documents as a document-based query language that is nearly as powerful as, or more powerful than, SQL.
- Mapping Not Required: Conversion or mapping of application objects to database objects isn't required.
- MongoDB supports Java-Script for server-side execution. MongoDB uses JSON format for data storage and retrieval at the client-side. In other words, it allows a developer to use a single programming language for both client-side and server-side code.
- MongoDB supports un-structured or semi-structured data.
- Uses internal memory for storing the (windowed) working set, enabling faster access to data.
- MongoDB is very easy to install and use.
Thanks for reading this article. In the next article, I will explain how to install MongoDB on your machine.

Sean FranklinPosted Mar 29, 2020, 1:30 PM
Thanks for this. I'll be going through this and the followup articles you shared on the subject
Khawar IslamPosted Feb 20, 2016, 12:38 PM
Nice
Sr KarthigaPosted Feb 14, 2016, 7:36 AM
Good one sir
Pankaj Kumar ChoudharyPosted Sep 5, 2015, 1:12 PM
Thanks for support...........
Amol SarkatePosted Sep 1, 2015, 8:39 AM
Thanks For giving valuable Information (new technology mongoDB)
Pankaj Kumar ChoudharyPosted Aug 29, 2015, 8:24 AM
Thanks Ratnesh Sir.......
Ratnesh SinghPosted Aug 28, 2015, 6:58 AM
Nice Article..
Pankaj Kumar ChoudharyPosted Aug 6, 2015, 12:17 PM
Thanks Anoop Kumar Sharma.............
Anoop Kumar SharmaPosted Aug 6, 2015, 9:47 AM
Nice Series. Thanks for Sharing..!!
Pankaj Kumar ChoudharyPosted Aug 4, 2015, 6:33 AM
Thanks Yashwant Vishwakarma Sir........
Yashwant VishwakarmaPosted Aug 4, 2015, 3:12 AM
Nice to see articles for MongoDB here , great one !!!
Pankaj Kumar ChoudharyPosted Aug 3, 2015, 3:07 PM
thanks Vignesh Mani Sir......
Pankaj Kumar ChoudharyPosted Aug 3, 2015, 3:06 PM
Thanks Mohammed Ibrahim Sir........
Pankaj Kumar ChoudharyPosted Aug 3, 2015, 3:06 PM
Thanks Rahul Prajapat..........
Pankaj Kumar ChoudharyPosted Aug 3, 2015, 3:06 PM
Thanks Debasis Saha Sir......
Pankaj Kumar ChoudharyPosted Aug 3, 2015, 3:05 PM
Thanks Pankaj Bajaj Sir. I hope you will post article on MongoDB and help to create a new category.........
Vignesh ManiPosted Aug 3, 2015, 6:37 AM
Nice one
Mohammed IbrahimPosted Aug 3, 2015, 6:18 AM
nice!!!
Rahul PrajapatPosted Aug 3, 2015, 2:32 AM
Nice pankaj sir
Upendra Pratap ShahiPosted Aug 3, 2015, 2:07 AM
nice Pankaj Kumar Choudhary
Debasis SahaPosted Aug 3, 2015, 12:56 AM
Nice one..
Pankaj BajajPosted Aug 3, 2015, 12:10 AM
gud one Pankaj. I am also looking into MongoDB these days.
Pankaj Kumar ChoudharyPosted Aug 2, 2015, 6:52 PM
Thanks Niplesh Sir..
Nipesh JanghelPosted Aug 2, 2015, 2:45 PM
Nice!!
Rakesh KalluriPosted Aug 2, 2015, 2:19 PM
Giod one.
Pankaj Kumar ChoudharyPosted Aug 2, 2015, 11:53 AM
Thanks Neeraj ........
Neeraj KumarPosted Aug 2, 2015, 11:16 AM
Good Pankaj Kumar Choudhary
Pankaj Kumar ChoudharyPosted Aug 2, 2015, 7:11 AM
Thanks Abhishek Sir for your Reply.........
Abhishek JaiswalPosted Aug 2, 2015, 5:29 AM
As of July 2015, MongoDB is the fourth most popular type of database management system, and the most popular for document stores because of its excellent features mentioned here by Pankaj. In current it is used by the giants like Adobe, eBay, Linkedin, Bosch, MetOffice, (now maybe some ppl won't ask why MongDB?). Meanwhile, nice read, waiting for more. Cheers!! :)
Rajeesh MenothPosted Aug 2, 2015, 5:18 AM
Good One Pankaj Kumar Choudhary
Pankaj Kumar ChoudharyPosted Aug 2, 2015, 4:42 AM
Thanks Sibeesh Sir........
Sibeesh VenuPosted Aug 2, 2015, 4:00 AM
Nice Share. Thank you
Gopi ChandPosted Aug 2, 2015, 2:50 AM
Nice intro :)
Santhakumar MunuswamyPosted Aug 2, 2015, 2:24 AM
Good show
RakeshPosted Aug 2, 2015, 1:42 AM
Good one