当前位置:网站首页>MYCAT horizontal sub table (E-R table)
MYCAT horizontal sub table (E-R table)
2022-04-21 18:11:00 【Chet Howe】
Mycat Horizontal sub table E-R surface
1.E-R surface
Relational database is based on entity relationship model (Entity-Relationship Model) above , It describes things and relationships in the real world ,
Mycat Medium ER Tables come from this . According to this idea , Based on E-R Data fragmentation strategy for relationships , The records of the sub table are associated with
The parent table records are stored on the same data partition , That is, the child table depends on the parent table , Group by table (Table Group) Guaranteed data Join No cross library operation
do .
Table grouping (Table Group) It's about solving cross slice data join It's a very good idea of , It is also an important rule of data segmentation planning .
2. modify schema.xml The configuration file
<table name = "orders_hor" dataNode = "dn1,dn2" rule = "mod_rule">
<!-- Add sub table configuration -->
<childTable name="orders_detail" primaryKey="id" joinKey="order_id" parentKey="id" />
</table>
3. Create table orders_detail
- master1 and master2 On
CREATE TABLE orders_detail(
id INT AUTO_INCREMENT,
detail VARCHAR(2000),
order_id INT,
PRIMARY KEY(id)
);
4. insert data
INSERT INTO orders_detail(id,detail,order_id) values(1,'detail1',1);
INSERT INTO orders_detail(id,detail,order_id) VALUES(2,'detail1',2);
INSERT INTO orders_detail(id,detail,order_id) VALUES(3,'detail1',3);
INSERT INTO orders_detail(id,detail,order_id) VALUES(4,'detail1',4);
INSERT INTO orders_detail(id,detail,order_id) VALUES(5,'detail1',5);
INSERT INTO orders_detail(id,detail,order_id) VALUES(6,'detail1',6);
5. verification
mysql> select * from orders_detail;
+----+---------+----------+
| id | detail | order_id |
+----+---------+----------+
| 1 | detail1 | 1 |
| 2 | detail1 | 2 |
| 6 | detail1 | 6 |
| 3 | detail1 | 3 |
| 4 | detail1 | 4 |
| 5 | detail1 | 5 |
+----+---------+----------+
6 rows in set (0.01 sec)
mysql> Select o.*,od.detail from orders_hor o inner join orders_detail od on o.id=od.order_id;
+----+------------+-------------+-----------+---------+
| id | order_type | customer_id | amount | detail |
+----+------------+-------------+-----------+---------+
| 3 | 101 | 101 | 120000.00 | detail1 |
| 4 | 101 | 101 | 103000.00 | detail1 |
| 5 | 102 | 101 | 100400.00 | detail1 |
| 1 | 101 | 100 | 100100.00 | detail1 |
| 2 | 101 | 100 | 100300.00 | detail1 |
| 6 | 102 | 100 | 100020.00 | detail1 |
+----+------------+-------------+-----------+---------+
6 rows in set (0.00 sec)
版权声明
本文为[Chet Howe]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211809161292.html
边栏推荐
- Logstash ~ input of logstash (input)
- Interface test framework practice (II) | interface request assertion
- Mycat水平分表(E-R表)
- Look at how the technology house saves Xueba machine. I repaired my laptop with 10 yuan
- 【NPJ|数字医药】医学影像的机器学习:方法学的失败和对未来的建议
- 【acwing】165. 小猫爬山(DFS之剪枝)
- [brush force buckle] questions 51-60
- Mobile platform workplus integrated office, creating a full scene business ecosystem for enterprises
- 中介者模式
- 【acwing】1118. 分成互质组 ***(DFS)
猜你喜欢

看看技术宅怎么拯救学霸机,我用10块钱修好了笔记本电脑

Headline we media operation secret script. If you stick to it, you can beat 90% of the people

单片机能做什么,你有什么有单片机或开源硬件做的有意思的作品吗

Finally someone made it clear! It turns out that this is the global one-piece network technology with low delay

看完这篇教程,你将拥有自己的一个卫星(diy全程详解)

Finally complete the dream of student age - make a handheld machine and teach you with single chip microcomputer STM32

不同研发协作模式在云效中的应用

The upper computer is fun to play like this!

最基本的JDBC模板及数据库乱码处理

Kubernetes详解(四)——基于kubeadm的Kubernetes部署
随机推荐
IoT平台如何实现业务配置中心
Download times remaining, link + email can be left
Appium source code analysis of dry goods app automated testing
【论文精读】Perception-based seam cutting for image stitching
STM32单片机内存管理器代码,可直接用于工程
Q:excel制作折线图
Logstash ~ logstash command line optional parameters
ansible简单使用示例
人员不足、供应链断裂,危机之下制造业该如何自救?
Live app source code, add picture display function on the basis of unable to display pictures
看看项目经理是如何把一个项目带崩的
LogStash~LogStash的input(input)
The conflict between Russia and Ukraine raised concerns. The five eye network security department suggested that allies strengthen the protection of key infrastructure
离散数学 命题逻辑
What happens when the user sends a request to execute the controller method
【无标题】
Easy to use example
安装网卡驱动失败(已解决)
Pytorch数据封装进入网络前的几种方式
SQL命令 DELETE(一)