1 What is a sub-library and sub-table
The situation discussed here is that one machine corresponds to one database.
The object of the sub-library is the table, and the object of the sub-table is the row. Sub-database means placing highly related tables belonging to the same module in the same database. Sub-table means dividing the rows of the same table into multiple sub-tables, and placing each sub-table in its own database.
2 Examples of sub-libraries and sub-tables
2.1 Vertical division
Now there are order tables and order after-sales tables in the order database. The former is factual, and the latter does not need real-time performance. Therefore, they are placed in two databases, one for the order table, and the other for the order after-sales table. .
2.2 Horizontal division
For example a user order database, each user has a unique user id.
If we now divide the user order database horizontally into 10 databases, then put the user id% 10, so that the rows with modulo 0 are placed in the first database, and the rows with modulo 1 are placed in the second database, and so on. analogy.
3 How to realize the transaction of sub-database and sub-table