MySQL Sub-database sub-table

Source: Internet
Author: User

1 What is a sub-database table

The situation discussed here is a database on a single machine.

The object of a library is a table, and the object of a table is a row. The Sub-Library is about placing tables that are highly correlated to the same module in the same database. The table is to say that the rows of the same table are divided into multiple sub-tables, and each child table is placed in its own database.

2 examples of sub-library tables

2.1 Vertical Partitioning

Now the order database has the order form and order after-sales table, the former is factual, the latter does not need real-time, so put them in two databases, a database placed in the order form, and another database placed in the order after the sales table.

2.2 Horizontal Division

For example, the user order database, each user has a unique customer ID.

If we now divide the user order database horizontally into 10 databases, then we will put users id%10, so that the rows with modulo 0 are placed in the first database, the rows with modulo 1 are placed in the second database, and so on.

3 How to implement the transaction of the sub-database table

4 How to implement cross-shard sorting paging

Before the Shard, sorted by ID, after the Shard, also want to sort by ID to return, how to implement?

5 Cross-node join

6 MySQL split-pants shard Middleware

Mycat

On Mycat, users can use SQL as if they were a single database.

For example, Mycat supports cross-node joins, and so on, Mycat supports transactions and implements acid.

Mycat not applicable to the scene:

pagination sorting, etc.

53178657

MySQL Sub-database sub-table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.