Two databases that have developed very well in different fields, MongoDB (NoSQL) and MYSQL (relational), record their differences and the environments they are used in.
MongoDB sacrifices space in exchange for strong scalability and a certain aspect of great speed improvement. .
simply put.
Relationship + transaction of relational database. Nosql headed by mongodb does not have
It takes about 2 hours to insert 1 million data into a relational database, taking mysql as an example, and it takes 3 minutes to insert 1 million data into mongodb. .
Insert 100w data, mongodb increased by 5G. The disk space of the mysql storage database has not increased significantly, not even 500M.
Query speed, mongodb is very fast.
But if you deal with the relationship, you will kneel down.
For a simple example, a financial system is designed to delete a user (user foreign key to the user’s consumption record buy table). All the user’s buy records are deleted at the database layer at one time without any errors.
But mongodb can’t do it, it doesn’t have foreign keys. We can only delete the user first, and then find out all the records belonging to this user in the buy and delete them, and if there is a problem in the process and it is terminated, resulting in the deletion of the user, the consumption records of the deleted user are still there, and the system will be disordered up. .