Difference: 1. MySQL is a relational database, while mongodb is a non-relational database; 2. MySQL supports multiple engines, and different engines have different storage methods, while mongodb stores it in a JSON-like document format. ; 3. MySQL uses traditional SQL statements for query, while mongodb has its own query method (similar to JavaScript functions); 4. MySQL occupies a small space and supports join, while mongodb takes up a large space and does not support join.
The operating environment of this tutorial: windows7 system, mysql8&&mongodb5 version, Dell G3 computer.
MySQL and MongoDB are both commonly used open source databases, but MySQL is a traditional relational database, while MongoDB is a non-relational database, also called a document database, and is a NoSQL database. They each have their own advantages, the key is where they are used. So the SQL statements we are familiar with are not applicable to MongoDB, because SQL statements are the standard language of relational databases.
1. There are different storage methods on different engines.
2. The query statement uses traditional sql statements and has a relatively mature system with high maturity.
3. The share of open source databases is constantly increasing, and the share of mysql pages is continuing to grow.
4. The disadvantage is that the efficiency will be significantly slower when processing massive data.
Non-relational database (nosql) is a document database. Let me first explain the document database, which can store data of xml, json, and bson types. These data are self-describing and present a hierarchical tree-like data structure. The data structure consists of key-value (key=>value) pairs.
1. Storage method: virtual memory persistence.
2. Query statement: It is a unique MongoDB query method.
3. Suitable scenarios: event recording, content management or blogging platform, etc.
4. Architectural features: High availability can be achieved through replica sets and sharding.
5. Data processing: The data is stored on the hard disk, but the data that needs to be read frequently will be loaded into the memory and the data will be stored in the physical memory to achieve high-speed reading and writing.
6. Maturity and breadth: Emerging databases have low maturity. Among Nosql databases, they are closest to relational databases and are one of the more complete DBs. The applicable population is constantly growing.
Advantages:
1. MongoDB with a moderate amount of memory The performance is very fast. It stores hot data in physical memory, making the reading and writing of hot data very fast.
2. MongoDB’s high availability and cluster architecture have very high scalability.
3. In the replica set, when the main database encounters a problem and cannot continue to provide services, the replica set will elect a new main database to continue to provide services.
4. MongoDB’s Bson and JSon format data are very suitable for document format storage and query.
Disadvantages:
1. Does not support transaction operations. MongoDB itself does not have its own transaction mechanism. If you need to implement a transaction mechanism in MongoDB, you need to use an additional table to logically implement the transaction yourself.
2. Less application experience. Due to the short rise of NoSQL, there is less application experience than relational databases.
3. MongoDB takes up too much space.
MongoDB | MySQL | |
---|---|---|
Non-relational | Relational | |
Storage in JSON-like document format | Different engines have different storage methods | |
MongoDB query Method (similar to JavaScript function) | SQL statement | |
Based on memory, hot data is stored in physical memory to achieve High-speed reading and writing | Different engines have their own characteristics | |
Emerging databases, lower maturity | Maturity High | |
Among NoSQL databases, it is relatively complete and open source, and the number of users is growing | Open source database, the market share is growing | |
Only supports single-document transaction operations, weak consistency | Supports transaction operations | |
Large space occupied | Small space occupied | |
MongoDB does not have join | MySQL support join |
mysql video tutorial]
The above is the detailed content of What is the difference between mysql and mongodb. For more information, please follow other related articles on the PHP Chinese website!