All About MongoDB NoSQL Database: Advantages and Disadvantages

How MongoDB Works?

MongoDB CRUD Operations

Example of MongoDB Operations

> use demoDB switched to db demoDB > show collections >
> db.createCollection("demoCollection") { "ok" : 1 } >
> db.demoCollection.insertOne({"name":"Dustin","age":19,"city":"New york"}) { "acknowledged" : true, "insertedId" : ObjectId("5d3b3d607d9aaf21ac74a3e4") } >
> db.demoCollection.find().pretty() { "_id" : ObjectId("5d3b3d607d9aaf21ac74a3e4"), "name" : "Dustin", "age" : 19, "city" : "New york" } >
> db.demoCollection.updateOne({"name":"Dustin"}, {$set : {"age":29}}) { "acknowledged" : true, "matchedCount" : 1, "modifiedCount" : 1 } >
> db.demoCollection.find().pretty() { "_id" : ObjectId("5d3b3d607d9aaf21ac74a3e4"), "name" : "Dustin", "age" : 29, "city" : "New york" } >
> db.demoCollection.deleteOne({"name":"Dustin"}) {"acknowledged" : true, "deletedCount" : 1 } > db.demoCollection.find().pretty() >
> db.demoCollection.drop() true >
> show collections >

Important Terms in MongoDB

  • Document: A document is a record in MongoDB where data is stored in key-value pairs.
  • Collection: A collection is a group of documents.
  • Database: A database is where all the collections are present.
  • Key-value pairs: Data in MongoDB is stored in JSON format. JSON stores data in key-value pairs.
  • JSON: It is a data-interchange format we use in MongoDB to store data.
  • BSON: BSON is extended JSON which supports a variety of data types.
  • _id: _id is a field auto-generated whenever a document is created. The value of _id is unique.

Advantages and Disadvantages of MongoDB

Advantages of MongoDB

  • MongoDB is a schema-less NoSQL database. We do not need to design the schema of the database when we are using MongoDB. This saves a lot of time. Thus, the code we write defines the schema.
  • No complex joins are needed in MongoDB. There is no relationship among data in MongoDB.
  • MongoDB is easy to scale.
  • It is very easy to set-up and install MongoDB.
  • The document query language supported by MongoDB is very simple as compared to SQL queries.
  • Because the MongoDB uses JSON format to store data, it is very easy to store arrays and objects.
  • MongoDB is free to use. There is no cost for it.
  • Performance of MongoDB is much higher than compared to any relational database.
  • There is no need for mapping of application objects to database objects in MongoDB.
  • MongoDB uses internal memory for storage which enables faster access to the data.

Disadvantages of MongoDB

  • MongoDB uses high memory for data storage.
  • There is a limit for document size, i.e. 16mb.
  • There is no transaction support in MongoDB.

MongoDB vs RDBMS

  • In RDBMS, We need to create tables, schemas, and relations first. But in MongoDB, there is no need for such tables, schema, and relations.
  • To join two tables, In RDBMS, we have to use joins which are a bit complex. But in MongoDB, there are no joins. We can change the structure of the document in such a way that the other document can be embedded inside the other.
  • We need to set the primary key of every table in RDBMS. MongoDB provides an _id field which is created itself with every document and it acts as the primary key.
  • Setting up a relational database is not easy while setting up MongoDB is very simple.
  • RDBMS is not suitable for hierarchical data storage while MongoDB is best for it.
  • RDBMS is slower as compared to NoSQL databases. MongoDB is 100 times faster than RDBMS.




Acodez is one of the leading digital marketing agency in India. We are also a renowned web design and web development company. Visit:

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

SPFx extension — Convert to PDF

What Makes a Good Programmer?

Are You Really a Good Full-Stack Developer?

Maintaining a Growing Open Source Project

Query hashing to reduce GraphQL Payload Size

Support And Maintenance: What Comes After The App Is Deployed?

My journey to Udacity AWS Machine Learning Scholarship.

How to Solve the Problem in Deprecating Facebook Login support on Android WebViews

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Acodez IT Solutions

Acodez IT Solutions

Acodez is one of the leading digital marketing agency in India. We are also a renowned web design and web development company. Visit:

More from Medium

FHIR for Developers: Part 1

Java Selective Lock By ConcurrentHashMap and ReentranLock

Criteria API (Introduction)

Java Couchbase |Mysql | Oracle Database Connect And Data Logger!