Home >Database >Mysql Tutorial >What is the difference between mysql and mongodb

What is the difference between mysql and mongodb

青灯夜游
青灯夜游Original
2022-06-16 14:39:1434222browse

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.

What is the difference between mysql and mongodb

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. 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. 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.


4. Comparison between MongoDB and MySQL (difference introduction)

##DatabaseMongoDBMySQL Database modelNon-relationalRelationalStorage MethodStorage in JSON-like document formatDifferent engines have different storage methodsQuery statementMongoDB query Method (similar to JavaScript function) SQL statementData processing methodBased on memory, hot data is stored in physical memory to achieve High-speed reading and writingDifferent engines have their own characteristicsMaturityEmerging databases, lower maturityMaturity HighBreadthness Among NoSQL databases, it is relatively complete and open source, and the number of users is growingOpen source database, the market share is growingTransactionalOnly supports single-document transaction operations, weak consistencySupports transaction operationsOccupancy Space Large space occupied Small space occupied join operationMongoDB does not have joinMySQL support join
[Related recommendations:

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!

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
Previous article:Why choose mysqlNext article:Why choose mysql