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, 9:30 AM EDT
Thanks for this. I'll be going through this and the followup articles you shared on the subject
Khawar IslamPosted Feb 20, 2016, 7:38 AM EST
Nice
Sr KarthigaPosted Feb 14, 2016, 2:36 AM EST
Good one sir
Pankaj Kumar ChoudharyTOP 100Posted Sep 5, 2015, 9:12 AM EDT
Thanks for support...........
Amol SarkatePosted Sep 1, 2015, 4:39 AM EDT
Thanks For giving valuable Information (new technology mongoDB)
Pankaj Kumar ChoudharyTOP 100Posted Aug 29, 2015, 4:24 AM EDT
Thanks Ratnesh Sir.......
Ratnesh SinghPosted Aug 28, 2015, 2:58 AM EDT
Nice Article..
Pankaj Kumar ChoudharyTOP 100Posted Aug 6, 2015, 8:17 AM EDT
Thanks Anoop Kumar Sharma.............
Anoop Kumar SharmaPosted Aug 6, 2015, 5:47 AM EDT
Nice Series. Thanks for Sharing..!!
Pankaj Kumar ChoudharyTOP 100Posted Aug 4, 2015, 2:33 AM EDT
Thanks Yashwant Vishwakarma Sir........
Yashwant VishwakarmaPosted Aug 3, 2015, 11:12 PM EDT
Nice to see articles for MongoDB here , great one !!!
Pankaj Kumar ChoudharyTOP 100Posted Aug 3, 2015, 11:07 AM EDT
thanks Vignesh Mani Sir......
Pankaj Kumar ChoudharyTOP 100Posted Aug 3, 2015, 11:06 AM EDT
Thanks Mohammed Ibrahim Sir........
Pankaj Kumar ChoudharyTOP 100Posted Aug 3, 2015, 11:06 AM EDT
Thanks Rahul Prajapat..........
Pankaj Kumar ChoudharyTOP 100Posted Aug 3, 2015, 11:06 AM EDT
Thanks Debasis Saha Sir......
Pankaj Kumar ChoudharyTOP 100Posted Aug 3, 2015, 11:05 AM EDT
Thanks Pankaj Bajaj Sir. I hope you will post article on MongoDB and help to create a new category.........
Vignesh ManiTOP 100Posted Aug 3, 2015, 2:37 AM EDT
Nice one
Mohammed IbrahimPosted Aug 3, 2015, 2:18 AM EDT
nice!!!
Rahul PrajapatPosted Aug 2, 2015, 10:32 PM EDT
Nice pankaj sir
Upendra Pratap ShahiPosted Aug 2, 2015, 10:07 PM EDT
nice Pankaj Kumar Choudhary
Debasis SahaTOP 100Posted Aug 2, 2015, 8:56 PM EDT
Nice one..
Pankaj BajajPosted Aug 2, 2015, 8:10 PM EDT
gud one Pankaj. I am also looking into MongoDB these days.
Pankaj Kumar ChoudharyTOP 100Posted Aug 2, 2015, 2:52 PM EDT
Thanks Niplesh Sir..
Nipesh JanghelPosted Aug 2, 2015, 10:45 AM EDT
Nice!!
Rakesh KalluriPosted Aug 2, 2015, 10:19 AM EDT
Giod one.
Pankaj Kumar ChoudharyTOP 100Posted Aug 2, 2015, 7:53 AM EDT
Thanks Neeraj ........
Neeraj KumarPosted Aug 2, 2015, 7:16 AM EDT
Good Pankaj Kumar Choudhary
Pankaj Kumar ChoudharyTOP 100Posted Aug 2, 2015, 3:11 AM EDT
Thanks Abhishek Sir for your Reply.........
Abhishek JaiswalPosted Aug 2, 2015, 1:29 AM EDT
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, 1:18 AM EDT
Good One Pankaj Kumar Choudhary
Pankaj Kumar ChoudharyTOP 100Posted Aug 2, 2015, 12:42 AM EDT
Thanks Sibeesh Sir........
Sibeesh VenuTOP 100Posted Aug 2, 2015, 12:00 AM EDT
Nice Share. Thank you
Gopi ChandPosted Aug 1, 2015, 10:50 PM EDT
Nice intro :)
Santhakumar MunuswamyPosted Aug 1, 2015, 10:24 PM EDT
Good show
RakeshPosted Aug 1, 2015, 9:42 PM EDT
Good one