Home Database Mysql Tutorial 关系型数据库和非关系型数据库的选择,以及替代方法(mysql替代mo

关系型数据库和非关系型数据库的选择,以及替代方法(mysql替代mo

Jun 07, 2016 pm 02:53 PM
mysql Relational database method substitute choose

关系型数据库和非关系型数据库的选择,以及替代方法(mysql替代mongodb) 我做的项目因为涉及到大量的历史数据增加而采用的非关系型数据(mongodb),但是在实际开过程中遇到了很多问题,有开发方面的,也有管理方面的,于是我思考了用关系型数据库mysql代替非

关系型数据库和非关系型数据库的选择,以及替代方法(mysql替代mongodb)

 

我做的项目因为涉及到大量的历史数据增加而采用的非关系型数据(mongodb),但是在实际开过程中遇到了很多问题,有开发方面的,也有管理方面的,于是我思考了用关系型数据库mysql代替非关系型数据库mongodb的思路。  www.2cto.com  

 

目前还没有实施,因为对项目的改动会很大,希望大家能看看我的思路,最好能提一些意见,谢谢各位了。

 

方案的核心在于将目前一个数据库分割为两个数据库,一个当前交易库,一个历史数据查询库。

  www.2cto.com  

---------------------------详细方案如下----------------------------------

 

建立两个mysql数据库,一个是当前业务库叫bussDB,一个是数据中心库叫datacenterDB。

 两个数据库如何运作: 

1、datacenterDB库和bussDB库表结构基本完全一致。bussDB库存放正在进行的交易,datacenterDB库存放当前正在进行的交易和所有历史交易。

2、业务后台管理系统和业务前台网站都直接连接bussDB库进行正常业务操作。

3、历史查询、分析统计系统连接datacenterDB库进行查询统计。

4、bussDB库按照适合oltp(交易型)的库进行数据库存储和建模的优化。

5、datacenterDB库按照适合olap(分析型、数据仓库)的库进行数据库存储和建模的优化,可以使用表分区和集群等技术。

6、每天晚上,自动定时通过ETL工具(数据库同步工具)将bussDB库中的信息自动同步到datacenterDB库中。

7、设置程序自动在交易完成后180天以后将交易信息清除,清除之后关于该交易的查询在datacenterDB库中查询。

 

为什么要分为两个数据库:

1、适合交易的数据库和适合分析的数据库建模有一定区别,bussDB是交易型,而datacenterDB是查询分析型。

2、bussDB库需要保证快速响应,不因为历史数据的不断增大而影响速度,因此需要定期清除数据和数据转存。

3、bussDB库是一个事务型的数据库,需要保证事务完整性,因此不适合做集群,应采取垂直扩展(高性能服务器)。

4、datacenterDB库是一个数据仓库的数据库,需要集群和水平扩展(廉价PC,做集群)。

 

为什么要用关系型数据库而不用非关系型数据库。

 

1、在以上方式设计的bussDB库的状态下,对于增删改查操作,关系型数据库和非关系型数据库的性能开销基本一致,因为所有表的数据量都非常小,小于百万级,因为在千万级数据量以下,关系型数据库只要设置了索引,都是非常快的。

2、在性能方面一致的情况下,非关系数据库的缺点在于无法支持动态连接查询应用,即sql中的join操作,或者说是join效率不如关系型数据库高,另外也不支持分组(group)和统计操作(count/sum/avg等),在业务系统中存在大量的join操作,比如,报表打印、银行缴费对账、员工、机构、角色、交易、科目、字典等复杂应用都涉及到大量关联,所以非关系型数据库在这些处理方面不如关系型数据库灵活和性能高,编写的代码可读性和健壮性也较低。

3、关系型数据库的管理工具比如sqlyong,比非关系型数据库的管理工具更丰富,也更完善。对于数据库的DBA维护而言,关系型数据库的批量更新、导入、导出、备份、优化等方式和资料都丰富,对于开发人员的入门门槛,关系型数据库也比较低。

4、关系型数据库的发展历史和稳定性要超过非关系型数据库。

5、既然在性能一致的情况下为什么不用关系型数据库呢。

6、datacenterDB库就必须是用关系型数据库了,因为datacenterDB大量的统计应用都是基于sql中的统计函数的,比如查询交易业务性别比例、学历分布等,都涉及到sql操作,比如,join,group by xxx,sum(),count(),avg()等,这些都是非关系型数据库不支持的。

 

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Do mysql need to pay Do mysql need to pay Apr 08, 2025 pm 05:36 PM

MySQL has a free community version and a paid enterprise version. The community version can be used and modified for free, but the support is limited and is suitable for applications with low stability requirements and strong technical capabilities. The Enterprise Edition provides comprehensive commercial support for applications that require a stable, reliable, high-performance database and willing to pay for support. Factors considered when choosing a version include application criticality, budgeting, and technical skills. There is no perfect option, only the most suitable option, and you need to choose carefully according to the specific situation.

RDS MySQL integration with Redshift zero ETL RDS MySQL integration with Redshift zero ETL Apr 08, 2025 pm 07:06 PM

Data Integration Simplification: AmazonRDSMySQL and Redshift's zero ETL integration Efficient data integration is at the heart of a data-driven organization. Traditional ETL (extract, convert, load) processes are complex and time-consuming, especially when integrating databases (such as AmazonRDSMySQL) with data warehouses (such as Redshift). However, AWS provides zero ETL integration solutions that have completely changed this situation, providing a simplified, near-real-time solution for data migration from RDSMySQL to Redshift. This article will dive into RDSMySQL zero ETL integration with Redshift, explaining how it works and the advantages it brings to data engineers and developers.

How to fill in mysql username and password How to fill in mysql username and password Apr 08, 2025 pm 07:09 PM

To fill in the MySQL username and password: 1. Determine the username and password; 2. Connect to the database; 3. Use the username and password to execute queries and commands.

Query optimization in MySQL is essential for improving database performance, especially when dealing with large data sets Query optimization in MySQL is essential for improving database performance, especially when dealing with large data sets Apr 08, 2025 pm 07:12 PM

1. Use the correct index to speed up data retrieval by reducing the amount of data scanned select*frommployeeswherelast_name='smith'; if you look up a column of a table multiple times, create an index for that column. If you or your app needs data from multiple columns according to the criteria, create a composite index 2. Avoid select * only those required columns, if you select all unwanted columns, this will only consume more server memory and cause the server to slow down at high load or frequency times For example, your table contains columns such as created_at and updated_at and timestamps, and then avoid selecting * because they do not require inefficient query se

MySQL: The Ease of Data Management for Beginners MySQL: The Ease of Data Management for Beginners Apr 09, 2025 am 12:07 AM

MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

How to view mysql How to view mysql Apr 08, 2025 pm 07:21 PM

View the MySQL database with the following command: Connect to the server: mysql -u Username -p Password Run SHOW DATABASES; Command to get all existing databases Select database: USE database name; View table: SHOW TABLES; View table structure: DESCRIBE table name; View data: SELECT * FROM table name;

How to optimize MySQL performance for high-load applications? How to optimize MySQL performance for high-load applications? Apr 08, 2025 pm 06:03 PM

MySQL database performance optimization guide In resource-intensive applications, MySQL database plays a crucial role and is responsible for managing massive transactions. However, as the scale of application expands, database performance bottlenecks often become a constraint. This article will explore a series of effective MySQL performance optimization strategies to ensure that your application remains efficient and responsive under high loads. We will combine actual cases to explain in-depth key technologies such as indexing, query optimization, database design and caching. 1. Database architecture design and optimized database architecture is the cornerstone of MySQL performance optimization. Here are some core principles: Selecting the right data type and selecting the smallest data type that meets the needs can not only save storage space, but also improve data processing speed.

See all articles