Formulating Sharding Rules

If an entity-relationship exists between data tables, formulate the same sharding rule for these tables, and select associated table fields as the sharding key. In this way, associated data in different tables is stored in one shard to avoid cross-shard JOIN.

For example, when creating sharded tables for customer tables, order tables, or order details tables, you are advised to select the customer ID as the sharding key.