Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Which is better, MongoDB or MySQL

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article shows you which is better, MongoDB or MySQL, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

What is MySQL / MariaDB?

MySQL AB's Monty Widenius and David Axmark first started developing MySQL in 1994. The "My" in the product name refers to the daughter of Widenius, not the English word "my". MySQL is designed to be compatible with mSQL (aka Mini). SQL), and added a SQL query layer and an open source license (actually a proprietary and GPL license). The public distribution of MySQL began at the end of 1996 and continues to be released every year or every two years. MySQL is currently the most popular relational database.

Sun Microsystems bought MySQL AB,Oracle for $1 billion in 2008 and Sun in 2010. Amid the widespread concern about Oracle's acquisition of MySQL, Widenius merged MySQL 5.5 into MariaDB before acquiring Oracle. MariaDB strives to maintain compatibility with the Oracle MySQL version.

MySQL started out as a fairly low-end relational database compared to more powerful business relational databases such as Oracle, IBM DB / 2, and Microsoft SQL Server, although it is sufficient to serve as a backup store for dynamic websites. Over the years, it has added most of the functionality you want from relational databases, including transactions, referential integrity constraints, stored procedures, cursors, full-text indexing and search, geographic indexing and search, and clustering.

Although MySQL now supports "large database" features, such as master-slave deployment, use with Memcached, and horizontal fragmentation, it is still commonly used in small and medium-sized deployments. Extending MySQL to multiple secondary servers can improve read performance, but only the primary server can accept write requests.

AWS provides two forms of MySQL as a service, namely Amazon RDS and Amazon Aurora. The latter has higher performance, can handle TB-level data, has less latency to update replicas, and can compete directly with Oracle databases and SQL Server.

What is MongoDB?

MongoDB is a highly scalable operational documentation database that can be used in both open source and commercial enterprise editions and can be run locally or as a managed cloud service. A managed cloud service is called MongoDB Atlas.

MongoDB is undoubtedly the most popular database in the NoSQL database. Its document data model provides great flexibility for developers, while its distributed architecture provides good scalability. Therefore, MongoDB is often chosen for applications that must manage large amounts of data, benefit from horizontal scalability, and handle data structures that are not suitable for relational models.

MongoDB is a document-based storage with a graph-based storage on top of it. MongoDB does not actually store JSON: it stores BSON (binary JSON), which extends the JSON representation (string) to include other types, such as int,long,date, floating point, decimal128, and geospatial coordinates.

MongoDB can use the type of data to generate the correct index type, resulting in multimodal graphics, geospatial, B-tree, and full-text indexes on a single copy of the data. MongoDB enables you to create an index on any document field. MongoDB 4 has multiple document transactions, which means that even if you have to standardize your data design, you can still get the ACID attribute.

By default, MongoDB uses dynamic mode, sometimes called modeless. Documents in a single collection do not need to have the same set of fields, and the data types of fields can vary from document to document in the collection. You can change the document structure at any time using dynamic mode.

However, architectural governance can be used. Starting with MongoDB 3.6, MongoDB supports JSON schema validation, which you can open in validator expressions.

LAMP and MEAN stack

There are many changes on the LAMP and MEAN stacks. For example, you can run on Windows (WAMP) or MacOS (MAMP) instead of Linux OS. You can run IIS (WIMP) instead of the Apache Web server on Windows.

You can run PostgreSQL or SQL Server instead of the MySQL relational database in the LAMP stack. If you need a global distribution, you can run CockroachDB or Google Cloud Spanner. You can use Perl or Python instead of the PHP language. If you want to code in Java or C #, you need to consider a separate stack series.

You can run Couchbase or Azure Cosmos DB for a better global distribution rather than the MongoDB document database in the MEAN stack. You can use any of the twelve Node.js Web server frameworks instead of Express. In addition to the AngularJS front-end framework, you can also run Angular 2 or React.

How to select a database for your application

The most important question to ask when selecting a database is:

How much data do you want to store when your application matures?

How many users do you want to handle at the same time under peak load?

What does your application need for availability, scalability, latency, throughput, and data consistency?

How often does your database schema change?

What is the geographical distribution of your user group?

What is the natural "shape" of your data?

Does your application need online transaction processing (OLTP), Analytical query (OLAP), or both?

What is your expected read-write ratio in production?

Do you need geographic query and / or full-text query?

What is your preferred programming language?

Do you have a budget? If so, will it cover licensing and support contracts?

Several of these issues tend to narrow the selection of the database, but we have more choices than when we set up the LAMP stack. If you are building an application that must be highly consistent with users around the world for 99.999% of the time, only a few databases are right for you. If your application will be used in a country from 9 a.m. to 6 p.m. on a weekday and can tolerate ultimate consistency, then almost all databases can be used. although some databases are easier for developers and operators, some databases can provide better performance for your main usage scenarios.

Although the LAMP and MEAN stacks are once a good solution for Web applications, neither is the best choice now. Instead of blindly adopting either, you should carefully consider use cases and find an architecture that can serve your application in the foreseeable future.

SQL or NoSQL?

When do you need a relational database (such as MySQL) for a new application? In addition to the explicit support for standard SQL, the relational database itself forces the data into a table schema with consistent strongly typed fields, and as long as you take advantage of normalization, it can help you avoid data duplication.

If you need to avoid losing data, NOT NULL can declare fields when you create or modify the table. If you need a geographic query defined by the Open Geospatial Alliance, most relational databases will provide a reliable implementation. Also, if you need full-text search, most relational databases allow you to define inverted table indexes on text fields, which FULLTEXT is called an index in MySQL.

On the other hand, if you need occasional free-form documents, MySQL and many other relational databases also support JSON data as defined by RFC 7159. If you also want to use XML documents and XPath or XSLT, most relational databases can provide this capability.

When do you need a document database like MongoDB? If your main use case needs to allow the use of free-form data, fields of type change between documents, schemas that change over time, or nested documents, the NoSQL database will meet the requirements. In addition, if your application is written in JavaScript, the JSON format of the document database will be natural.

The above content is which is better, MongoDB or MySQL? have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report