Business sub-library, vertical split, horizontal split

Business sub-library, vertical split, horizontal split

 

The common methods of sub-library are horizontal and vertical. Generally speaking, the database is divided according to user attributes (city or ID hash), or the database is divided according to business function blocks. 

Horizontal database splitting method: split physical database according to user attributes (such as city). A common way is to divide the province into several large regions. 

Vertical database partitioning method: According to business dimensions and data access, the data is separated and separated into multiple databases. For example, some common configuration information is stored in a database for separate maintenance.

 

 

vertical division

According to the function division, the data are placed in different databases and servers.

 

In fact, in a large and bloated database, a lot of data between tables and tables is irrelevant, or there is no need for (join) operations. In theory, they should be placed on different servers. For example, the data of the user's favorites and the database of the blog can be placed on two separate servers. This is called vertical division. 



 When the data of blogs or favorites keeps increasing, what should we do? This leads to another method called horizontal division.

 

 

horizontal division

 

Then, the data of one table is divided into different databases, and the table structure of the two databases is the same. How to divide it should be based on certain rules, which can be guided by the data generator. The above data is generated by people, and the database can be divided according to the id of the person. Then according to certain rules, first know which database the data is in.

 

Taking the blog just now as an example, the data can be divided according to the parity of the userid. Put the id as the base number in the A library, and the even number in the B library.



 
In this way, through the userId, you can know which database the data of the user's blog is in. In fact, it can be processed according to userId%10. It can also be processed according to the well-known Hash algorithm.

 

 

Notice:

a. It is best to assign them to the same database. 

b. A solution that has been proven to be feasible: main table + auxiliary table. 

c. There are 3 types: the main table is not broken, the main table is broken without auxiliary table, the main table is broken with auxiliary table. 

 

d. But for programmers, what TA sees is just a table, which may be called a virtual table (logical table)? This virtual table may actually be composed of N real tables (physical tables).

 

refer to:

http://blog.csdn.net/xingjing1226/article/details/51907220

http://blog.csdn.net/zljjava/article/details/38422387

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326493257&siteId=291194637