Note the sub_parent_id field, which enables you to associate data from the Tb_point_group_tree table as a tree data structure table.
CREATE TABLE' tb_point_group_tree ' (' cgroup_id ' )int( One) not NULL DEFAULT '0', ' group_id 'int( One) not NULLauto_increment, ' company_id 'int( One)DEFAULT NULL, ' group_name 'varchar( -)DEFAULT NULL, ' group_type_id 'int( One)DEFAULT NULLCOMMENT'Group Type: A general group, the type of electricity, the area of electricity, the production process, the key equipment', ' sub_parent_id 'int( One)DEFAULT '0'COMMENT'The Grouping Type subkey number is a self-associated gruoup_id, and if it is a parent, the value is 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= the DEFAULTCHARSET=UTF8 COMMENT='Each company can define multiple monitoring groups to facilitate management';
MySQL build self-correlating table example