What is MongoDB database, its working, pros & cons and difference between MongoDB(NoSQL) and MySQL(RDBMS) ?

What is MongoDB database, its working, pros & cons and difference between MongoDB(NoSQL) and MySQL(RDBMS) ?

What is MongoDB database ?

MongoDB is a document-oriented NoSQL database system that provides high scalability, flexibility, and performance. Unlike standard relational databases, MongoDB stores data in a JSON document structure form. This makes it easy to operate with dynamic and unstructured data and MongoDB is an open-source and cross-platform database System.

Where to use MongoDB ?

  • Mobile and Social Infrastructure

  • Data Hub

  • Previous Pag

  • Big Data

  • User Data Management

  • Content Management and Delivery

Advantages of MongoDB :

  • It is a schema-less NoSQL database. You need not to design the schema of the database when you are working with MongoDB.

  • It does not support join operation.

  • It provides great flexibility to the fields in the documents.

  • It contains heterogeneous data.

  • It provides high performance, availability, scalability.

  • It supports Geospatial efficiently.

  • It is a document oriented database and the data is stored in BSON documents.

  • It also supports multiple document ACID transition(string from MongoDB 4.0).

  • It does not require any SQL injection.

  • It is easily integrated with Big Data Hadoop

Disadvantages of MongoDB :

  • It uses high memory for data storage.

  • You are not allowed to store more than 16MB data in the documents.

  • The nesting of data in BSON is also limited you are not allowed to nest data more than 100 levels.

How MongoDB works ?

MongoDB is an open-source document-oriented database. It is used to store a larger amount of data and also allows you to work with that data. MongoDB is not based on the table-like relational database structure but provides an altogether different mechanism for storage and retrieval of data, that’s why known as NoSQL database. Here, the term ‘NoSQL’ means ‘non-relational’. The format of storage is called BSON ( similar to JSON format).

Now, let’s see how actually this MongoDB works? But before proceeding to its working, first, let’s discuss some important parts of MongoDB –

  • Drivers: Drivers are present on your server that are used to communicate with MongoDB. The drivers support by the MongoDB are C, C++, C#, and .Net, Go, Java, Node.js, Perl, PHP, Python, Motor, Ruby, Scala, Swift, Mongoid.

  • MongoDB Shell: MongoDB Shell or mongo shell is an interactive JavaScript interface for MongoDB. It is used for queries, data updates, and it also performs administrative operations.

  • Storage Engine: It is an important part of MongoDB which is generally used to manage how data is stored in the memory and on the disk. MongoDB can have multiple search engines. You are allowed to use your own search engine and if you don’t want to use your own search engine you can use the default search engine, known as 'WiredTiger' Storage Engine which is an excellent storage engine, it efficiently works with your data like reading, writing, etc.

Now, let's understand the working of MongoDB from below image.

Difference between MongoDB & MySQL

MongoDBMySQL
MongoDB is an open-source database developed by MongoDB, Inc. MongoDB stores data in JSON-like documents that can vary in structure. It is a popular NoSQL database.MySQL is a popular open-source relational database management system (RDBMS) that is developed, distributed and supported by Oracle Corporation.
In MongoDB, each individual records are stored as ‘documents’.In MySQL, each individual records are stored as ‘rows’ in a table.
Documents belonging to a particular class or group as stored in a ‘collection’. Example: collection of users.A ‘table’ is used to store rows (records) of similar type.
MongoDB is what is called a NoSQL database. This means that pre-defined structure for the incoming data can be defined and adhered to but also, if required different documents in a collection can have different structures. It has a dynamic schema. Example : if you want new field can be inserted irrespective of the schema and is thus known to have dynamic schema.MySQL as the name suggests uses Structured Query Language (SQL) for database access. The schema can not be changed. The inputs following the given schema are only entered. Example : In a table, if there are columns for name, address and there is need to enter ‘age’ in new column in one of the entries, it will not take it as the column is not defined in schema.
MongoDB was designed with high availability and scalability in mind, and includes out-of-the-box replication and sharding.MySQL concept does not allow efficient replication and sharding but in MySQL one can access associated data using joins which minimizes duplication.

Thanks for reading, i will write more blogs on mongoDB where i will cover all the mongoDB queries from basic to advanced and if this blog get helpful to you then please like 👍 and share...