MongoDB-Open Source Document Database


MongoDB is a Document Oriented Database, OpenSource NoSQL database.
MongoDB works on concept of Document and Collection.
Here is difference of RDBMS and MongoDB

Database Database
Table Collection
Tuple/Row Document
Column Field
Table Join Embedded Documents
Primary Key Primary Key (Default key _id provided by MongoDB itself)

Database is a physical container of data where each database has their own set of files. In the MongoDB server, there can be multiple databases.

Collection is a set of documents (Tuples). A collection exists within a single MongoDB database. Collections do not impose a schema. In collection documents can have different fields.

A document is a set of json or bson structure file having key value pair. Documents have a dynamic schema, means documents in the same collection can have different fields/structure, and common fields in a collection’s documents may have different types of data.
It can handle big data because it is document-oriented database it uses the format like JSON which called as BSON. Below example is a tabular format of a collection of MongoDB database.

Table: Person                                                                            Table: Bike

P_Id Surname First_name City
1 Sharma Piya Mumbai
2 Ahuja Ansh Pune
C_Id Model P_Id
1 Royal Enfield 1
2 Java 2
3 Hero 2
4 Yamaha 1

In MongoDB record known as field. Below format is shows how field is performing insert operation in MongoDB.

Collection: Person


“_id”: ObjectId(“5ba48782af8aacfcdead3a68”)
“Surname”: “Sharma”,
“First_Name”: “Piya”,
“City”:” Mumbai”,
“Bikes”: [
“Model”:”Royal Enfield”
}]   }

“_id”: ObjectId(“5ba48782af8aacfcdead3a69″)
“Surname”: “Ahuja”,
“First_Name”: “Ansh”,
“City”:” Pune”,
“Bikes”: [{“Model”:”Hero”},
{“Model”:”Java”}]   }

In MongoDB id key value is same as primary key of relation database it is provided by MongoDB as default key. In MongoDb it is not necessary to have same key field to insert data in multiple table as relational database.

Also we can add embedded data model to here is the one example of it

“_id” : ObjectId(“5ba48782af8aacfcdead3a69”),
“title” : “Harry Potter”,
“description” : “Novel by J. K. Rowling”,
“by” : “Chris Columbus”,
“tags” : [
“Harry Potter”,
“Lord Voldemort”,
“Hermione Granger”
“likes” : 120,     

“soldby” : [{“City” : “London”,
“Shop” : “Story Book Shop”,
}        ]}

Here ‘soldby’ is embedded document.

Please follow below steps for Installation Guide,

Follow below link to download MongoDB to System:

Step 1:

Step 2:

After install MongoDB compass create folder in ‘C’ drive name folder as data (C:\data)
Create new folder in ‘data’ folder name as db (“C:\data\db”).

Step 3:
Open command Prompt as “Run as administrator”. Write path of mongodb’s exe file to operate MongoDB server.
Path: C:\Program Files\MongoDB\Server\3.6\bin
Command: mongod.exe

As shown in below image:

Step 4:
To execute queries of MongoDB open another window of command prompt and run it as “Run as Administrator” and write ‘mongod‘ command to open localhost server and after that to execute queries with MongoDB write ‘mongo‘ command as shown in the image.

Command: mongod

Command: mongo

It will create localhost port 27017 as default server. Using this port, we can connect MongoDB compass software to operate MongoDB database as shown in below image.







Compass Software


Ad Hoc queries
MongoDB supports search by field, range queries, and regular expression searches.

Any field in a document can be indexed.

It supports master-slave replication. A master can perform read and write. A slave copies data from master and can only is used for reads or backup. (Not writes)

Duplication of data
Run over multiple servers. The data is duplicated to keep the system up and keep running in case of hardware failure.

Load balancing

MongoDB supports concurrent queries, both reads and writes, using a granular locking system.

So it is automatically deploying secondary node, the primary node can handle concurrent queries by itself.

High Scalability
MongoDB supports horizontal scaling through sharding, distributing data across several machines and facilitating high throughput operations with large sets of data. Sharding allows you to add additional thread to increase capacity.

File Storage
It could be used as a file system, taking advantage of load balancing and data replication features. Its provide GridFS for this purpose.

MapReduce can be used for processing of large data set and aggregation operation. It is offers same functionality as SQL Group by clause.

Server-side execution
If you need some operations to be performed on the server side and not in your application, you can do that in your MongoDB. Put your list of mongo statements in a Javascript file and execute it.

Special support for location
It understands longitude and latitude natively by using location feature we can write query to get location.

Capped collection
This type of collection maintains insert order and once the specified size has been reached, behaves like a circular queue. Capped collection used for storing log information, cache data, or any other high volume data. It is preventing data to update size more than allocate.


It is available in various platforms:

  1. Windows
  2. Linux
  3. OS X
  4. Solaris
    Use Cases of MongoDB

It could be used in Big Data Application and Traditional Application also.

It is suitable for smaller application but not suitable for application which involves a complex transaction.
In MongoDB it easy to use in Object Oriented Languages because it is no conversation required.

The Unique Identification Authority of India (UIDAI) is one of the suitable examples of MongoDB of real world. India’s Unique Identification project, aka aadhar. It is the world’s biggest biometric database. Aadhar is expected to capturing data to over a billion citizens Aadhar has used MongoDB as one of its databases to store this big amount of data.

Shutterfly is one of the companies that transitioned from Oracle to MongoDB. It is a popular internet-based photo sharing and personal publishing company that manages a store of more than 6 billion images with a transaction rate of up to 10,000 operations per second.

MetLife is a largest global provider of insurance, annuities and employee benefit programs. MetLife uses MongoDB for “MetLife Wall”, an innovative customer service application that provides a consolidated view of MetLife customers, including policy details and transactions. It is build function like Facebook and has improved customer satisfaction.

eBay is an American multinational customer-to-customer corporation. eBay has a lot of projects running on MongoDB for merchandizing categorization, metadata storage, cloud management and search suggestions.

Advantages and Disadvantages of MongoDB


  • Document oriented with Dynamic – No rigid schema & No Joins
  • High performance, availability – Replication, scalability -Sharding
  • Flexible – less/no impact on the application in case of field addition/deletion
  • Distributed
  • Data is stored as JSON or BSON
  • Geospatial support
  • Easy to Integrate with BigData Hadoop
  • Document-based query language
  • Easy integration in cloud distributions such as AWS, Microsoft and RedHat etc.


  • A downside of NoSQL is that most solutions are not as strongly ACID-compliant (Atomic, Consistency, Isolation, and Durability) as the more well-established RDBMS systems.
  • Complex transaction
  • function or stored procedure is not supported to write logic.

MongoDB is Suitable For,

  • E-commerce product.
  • Blogs, content and configuration management.
  • Real-time analytics and logging, caching, and high scalability.
  • Maintaining location-based data.
  • Mobile and social networking sites.
  • Loosely coupled — the design may change by over time.

Not Suitable For

  • Systems where the data model is designed up front.
  • High transaction volume
  • Systems which are tightly coupled

Leave a Reply

Your email address will not be published. Required fields are marked *