Get the App
SLTechnology News&Howtos  ›  Development  › 

Example analysis of MySQL sub-database and sub-table

Shulou Source: shulou.com Published: 2022-06-03 17:19:19 09月30日 Update

This article mainly shows you the "MySQL sub-library sub-table example analysis", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn the "MySQL sub-library sub-table example analysis" this article.

I. objectives

This article will achieve the following objectives:

Number of sub-tables: 256 sub-libraries: 4

Taking user ID (user_id) as database slicing Key

Finally, test order creation, update, delete, order number query, according to user_id query list operation.

Architecture diagram:

The table structure is as follows:

CREATE TABLE `order_ XXX` (`order_ id` bigint (20) unsigned NOT NULL, `user_ id` int (11) DEFAULT'0' COMMENT 'order id', `status` int (11) DEFAULT' 0' COMMENT 'order status', `booking_ date` datetime DEFAULT NULL, `create_ time` datetime DEFAULT NULL, `update_ time` datetime DEFAULT NULL, PRIMARY KEY (`order_ id`), KEY `idx_user_ id` (`user_ id`), KEY `idx_ bdate` (`booking_ date`), KEY `idx_ ctime` (`create_ time`) KEY `idx_ utime` (`update_ time`) ENGINE=InnoDB DEFAULT CHARSET=utf8

Note: 000

Tags: Sub-table sub-database data policy order user test configuration example analysis content database quantity environment article order number global field constant sequence Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info Microsoft vpn macOS