What is MongoDB? What does MongoDB do?
MongoDB is a type of open-source document database, it’s a NoSQL database, it’s not used in SQL statements, it’s not focused on building data relationships, it’s a structure that the owner of NoSQL creates and stores the data as a form. JSON (JavaScript Object Notation) which stores the values as key and value. Where the highlight is mainly in the speed of work querying data faster. The functionality of the database will be reduced, but instead will focus on working on the developed program. This type of database will be suitable for large data. That is not complicated, the work is not very hard. Able to work with a system that is working in real-time.

Usually, if we are familiar with MySQL, we will be familiar with Relation, also known as Join Relation between tables, which is the advantage of this type of RDBMS database (Relational Database Management System). But when it is a NoSQL database, it will not be stored. There is a way to store, but you must understand that it wasn’t born to be that kind of database.
MongoDB stores data as JSON documents, while MySQL stores table and row data, the most obvious difference. To store data as JSON document in MongoDB, it is not necessary to define the structure of collections before MySQL (in MongoDB we will call table collection and row is a document).
What is more important to MongoDB is that it is much faster, as MongoDB doesn’t have a relation like RDBMS like MySQL, its structure as a JSON object is much faster to read. That also depends on how we write and design our database.
Compare MongoDB and MYSQL.
Let’s take a look at the comparison table first. For mutual understanding What structures in MongoDB are comparable to in MySQL.

Storage format MongoDB
- Collections: collections of documents in MongoDB are stored in collections, comparable to tables in most relational databases, but, unlike collections, you do not need to have the same schema.
- Schemaless means that you don’t have to define any structure like normal SQL, for example, collection user, only store name, later you can add position storage.
Pros of MongoDB
- MongoDB is a document-oriented database. The storage style will use the JSON style format, with each row not necessarily having the same data structure, for example:

- MongoDB uses the same memory management system as cached memory in linux, which allows the OS to manage the memory.
- Uses Javascript for handling information.
- MongoDB is a full index, that is, it supports a huge amount of data. You can search for any part of the information.
- MongoDB supports adding or shrinking fields quickly without the need for an alter table command.
- Read and write fast data.
- Write asynchronous data (similar to MYISAM’s INSERT DELAYED in MySQL), meaning you don’t have to wait for the insert to finish and you can continue working.
- MongoDB has a capped collection, which will gradually delete the old data that has been stored too long and replace it with new data. Data does not grow larger than we set.
- Find information fast.
- Able to use a server that does not require very high quality, but can share many machines. Which is more economical than using a single high-quality device.
- Can be written in a set of instructions it is similar to writing PL / SQL.
Cons of MongoDB
- If the old project has a complicated JOIN, it will be difficult to switch to MongoDB.
- It takes up a lot more storage space than MySQL because it doesn’t have a schema, so schema actually resides in every row of the database, making the data bigger than MySQL.
- If the disk is full, it will clear the disk space to be difficult to use, because deleting row does not make the database smaller, you have to command the compact itself, which requires as much space on the other disk as the current data space. buffer to reduce size.
- To use it as the primary database instead, MySQL should have at least three separate physical machines replicating each other to increase the durability of the data since most of MongoDB’s data is stored in memory for a period of time. If the power goes off data that remains in the Memory but has not been written to disk will be lost immediately.
I hope this blog will help you understand MongoDB and what is different than MySQL. I would recommend trying to use it in your project, which will make you understand and learn more about MongoDB.