Home >Common Problem >What is the difference between mongodb and mysql

What is the difference between mongodb and mysql

百草
百草Original
2023-07-18 10:44:412039browse

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.

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, and it will store hot data In physical memory, reading and writing hot data becomes 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.

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn