How is MongoDB different from SQL database

Generally speaking, there are two main types of databases: SQL databases and NoSQL databases

For example, if you are familiar with MySQL or PostgreSQL, a SQL database allows you to add and retrieve data using a specific language called SQL, as follows:

INSERT INTO cars VALUES (fiesta, 2010)

SQL is quite old, born in 1986, is a tried and tested technology.

underNoSQLWe put all databases that do not use SQL language in the query data.

MongoDBFalling under this umbrella.

MongoDB is aDocument database. We don’t store records, but objects (calledDocuments).

How is this different from SQL databases? The table in the SQL database isflatwithstill, They can host data, but only for the original intent (you cannot add columns dynamically), and to store complex data, you need to follow the usual practices of relational databases (for example, foreign keys, column types, etc.).

In MongoDB, you can store any object without worrying about the specific fields that make up the object and how to store them. You tell MongoDB to store the object.

With MongoDB, you don't need to learn another language to interact with data: you only need to call the JavaScript methods it exposes (of course, you can also interact with it in other languages).

Data is stored in a format similar to JSON, but after enhancements, it can store more than just basic data types.

I hope this gives you a brief overview of the main differences between SQL databases and MongoDB.

More database tutorials: