🚀 优质资源分享 🚀
学习路线指引(点击解锁) | 知识定位 | 人群定位 |
---|---|---|
🧡 Python实战微信订餐小程序 🧡 | 进阶级 | 本课程是python flask+微信小程序的完美结合,从项目搭建到腾讯云部署上线,打造一个全栈订餐系统。 |
💛Python量化交易实战💛 | 入门级 | 手把手带你打造一个易扩展、更安全、效率更高的量化交易系统 |
日常开发过程过程中。树形结构运用的非常频繁。
例如:公司组织结构、各种分类结构、分组结构等等。
SET FOREIGN\_KEY\_CHECKS = 0;
CREATE TABLE IF NOT EXISTS `tbl\_sapo\_group` (
`id` int(10) unsigned NOT NULL AUTO\_INCREMENT COMMENT '主键',
`code` varchar(100) NOT NULL COMMENT '唯一编码',
`create\_time` datetime(3) NOT NULL COMMENT '创建时间',
`last\_update\_time` datetime(3) DEFAULT NULL COMMENT '最后更新时间',
`name` varchar(255) NOT NULL COMMENT '名称',
`detail` varchar(255) DEFAULT NULL COMMENT '详情',
`status` int(10) unsigned NOT NULL DEFAULT 2 COMMENT '状态:0-无效,1-有效,2-编辑',
`group\_type` varchar(100) NOT NULL COMMENT '组类型',
PRIMARY KEY (`id`),
UNIQUE KEY `uni\_idx\_group\_code` (`code`),
KEY `idx\_group\_group\_type` (`group\_type`),
CONSTRAINT `fk\_group\_group\_type` FOREIGN KEY (`group\_type`) REFERENCES `tbl\_sapo\_group\_type` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='组';
CREATE TABLE IF NOT EXISTS `tbl\_sapo\_group\_rel` (
`id` int(10) unsigned NOT NULL AUTO\_INCREMENT COMMENT '主键',
`create\_time` datetime(3) NOT NULL COMMENT '创建时间',
`last\_update\_time` datetime(3) DEFAULT NULL COMMENT '最后更新时间',
`parent\_code` varchar(100) NOT NULL COMMENT '父节点代码,tbl\_sapo\_group表code',
`child\_code` varchar(100) NOT NULL COMMENT '子节点代码,tbl\_sapo\_group表code',
`status` int(10) unsigned NOT NULL DEFAULT 2 COMMENT '状态:0-无效,1-有效,2-编辑',
`group\_rel\_type` varchar(100) NOT NULL COMMENT '组关系类型代码,来自tbl\_sapo\_group\_rel\_type表code',
`tree\_code` varchar(100) NOT NULL COMMENT '树节点代码,tbl\_sapo\_tree表code',
PRIMARY KEY (`id`),
KEY `idx\_group\_rel\_child\_code` (`child\_code`),
KEY `idx\_group\_rel\_parent\_code` (`parent\_code`),
KEY `idx\_group\_rel\_group\_rel\_type` (`group\_rel\_type`),
KEY `idx\_group\_rel\_tree\_code\_status\_parent\_code\_child\_code` (`tree\_code`,`status`,`parent\_code`,`child\_code`),
CONSTRAINT `fk\_group\_rel\_child\_code` FOREIGN KEY (`child\_code`) REFERENCES `tbl\_sapo\_group` (`code`),
CONSTRAINT `fk\_group\_rel\_group\_rel\_type` FOREIGN KEY (`group\_rel\_type`) REFERENCES `tbl\_sapo\_group\_rel\_type` (`code`),
CONSTRAINT `fk\_group\_rel\_parent\_code` FOREIGN KEY (`parent\_code`) REFERENCES `tbl\_sapo\_group` (`code`),
CONSTRAINT `fk\_group\_rel\_tree\_code` FOREIGN KEY (`tree\_code`) REFERENCES `tbl\_sapo\_tree` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='组关系';
CREATE TABLE IF NOT EXISTS `tbl\_sapo\_group\_rel\_type` (