标签:
注意sub_parent_id字段,通过该字段,可以将tb_point_group_tree表中的数据自关联为一个树形的数据结构表格。
CREATE TABLE `tb_point_group_tree` ( `cgroup_id` int(11) NOT NULL DEFAULT ‘0‘, `group_Id` int(11) NOT NULL AUTO_INCREMENT, `company_Id` int(11) DEFAULT NULL, `group_name` varchar(100) DEFAULT NULL, `group_type_id` int(11) DEFAULT NULL COMMENT ‘分组类型:-1—普通分组,-2—用电类型,-3—区域用电,-4—生产流程,-5—重点设备‘, `sub_parent_id` int(11) DEFAULT ‘0‘ COMMENT ‘分组类型子项编号为自关联的gruoup_Id,如果是父项,则该值为0‘, PRIMARY KEY (`group_Id`), KEY `FK_Reference_40` (`company_Id`) USING BTREE, KEY `tb_sub_parent_id_FK` (`sub_parent_id`), CONSTRAINT `tb_point_group_tree_ibfk_1` FOREIGN KEY (`company_Id`) REFERENCES `tb_customer_info` (`customer_Id`), CONSTRAINT `tb_sub_parent_id_FK` FOREIGN KEY (`sub_parent_id`) REFERENCES `tb_point_group_tree` (`group_Id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT=‘每个公司可以定义多个监测组,以方便管理‘;
标签:
原文地址:http://www.cnblogs.com/jayzee/p/4403660.html