The difference between MongoDB and MySQL: 1. MySQL is a traditional relational database, while MongoDB is a non-relational database; 2. MySQL has different storage methods on different engines, while MongoDB’s storage method is " Virtual memory persistence"; 3. MySQL uses traditional sql statements and so on.
The operating environment of this article: Windows 7 system, Mysql version 5.7.14, Dell G3 computer.
What is the difference between MongoDB and MySQL?
The difference between MongoDB and MySQL
Foreword:
MySQL and MongoDB are both open source and commonly used databases, but MySQL is MongoDB is a traditional relational database, a non-relational database, also called a document database, and 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. Relational database-MySQL
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.
2. Non-relational database-MongoDB
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.
3. Advantages and Disadvantages of MongoDB
Advantages:
1. The performance of MongoDB with a moderate amount of memory is very fast, it will Hot data is stored in physical memory, making 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.
4. Comparison
Database | MongoDB | MySQL |
---|---|---|
Database model | Non-relational | Relational |
Storage method | Stored in a JSON-like document format | Different engines have different storage methods |
Query statement | MongoDB query method ( JavaScript-like function) | SQL statement |
Data processing method | Based on memory, hot data is stored in physical memory to achieve high-speed reading Writing | Different engines have their own characteristics |
Maturity | Emerging databases, lower maturity | High maturity |
Breadthness | NoSQL database is relatively complete and open source, and the number of users is growing | Open source database, the market share is growing |
Transactional | Only supports single document transaction operation, weak consistency | Supports transaction operation |
Occupies space | Big space occupied | Small space occupied |
Join operation | MongoDB does not have join | MySQL supports join |
Above~
Recommended study: "mysql video tutorial"
The above is the detailed content of What is the difference between MongoDB and MySQL. For more information, please follow other related articles on the PHP Chinese website!