DROP TABLE
IF
	EXISTS entity_class;
CREATE TABLE entity_class (
	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '实体类ID',
	`name` VARCHAR ( 255 ) NULL COMMENT '实体类名称',
	`desc` VARCHAR ( 1023 ) NULL COMMENT '实体类描述',
	back_ground_color VARCHAR ( 15 ) NULL COMMENT '实体类背景颜色',
	create_by VARCHAR ( 64 ) NULL COMMENT '创建者',
	create_time datetime NULL COMMENT '创建时间',
	update_by VARCHAR ( 64 ) NULL COMMENT '更新者',
	update_time datetime NULL COMMENT '更新时间',
PRIMARY KEY ( id )
) ENGINE = INNODB auto_increment = 1 COMMENT = '实体类';

DROP TABLE
IF
	EXISTS entity_class_relation;
CREATE TABLE entity_class_relation (
	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '实体类关系ID',
	`name` VARCHAR ( 255 ) NULL COMMENT '实体类关系名称',
	`desc` VARCHAR ( 1023 ) NULL COMMENT '实体类关系描述',
	back_ground_color VARCHAR ( 15 ) NULL COMMENT '实体类关系背景颜色',
	start_id BIGINT ( 20 ) COMMENT '起点实体类id',
	end_id BIGINT ( 20 ) COMMENT '起点实体类id',
	create_by VARCHAR ( 64 ) NULL COMMENT '创建者',
	create_time datetime NULL COMMENT '创建时间',
	update_by VARCHAR ( 64 ) NULL COMMENT '更新者',
	update_time datetime NULL COMMENT '更新时间',
PRIMARY KEY ( id )
) ENGINE = INNODB auto_increment = 1 COMMENT = '实体类关系';

DROP TABLE
IF
	EXISTS t_build_entity_relation;
CREATE TABLE t_build_entity_relation (
	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
	sub_task_id BIGINT ( 20 ) COMMENT '子任务id',
	sub_entity_class_id BIGINT ( 20 ) COMMENT '主体实体类id',
	obj_entity_class_id BIGINT ( 20 ) COMMENT '客体实体类id',
	entity_class_rel_id BIGINT ( 20 ) COMMENT '实体类关系id',
	sub_entity VARCHAR ( 511 ) COMMENT '主体',
	obj_entity VARCHAR ( 511 ) COMMENT '客体',
	create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
	create_time datetime COMMENT '创建时间',
	update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
	update_time datetime COMMENT '更新时间',
PRIMARY KEY ( id )
) ENGINE = INNODB auto_increment = 1 COMMENT = '实体构建表';

DROP TABLE
IF
	EXISTS t_build_flow;
CREATE TABLE t_build_flow (
	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
	error_code VARCHAR ( 64 ) DEFAULT '' COMMENT '故障编码',
	flow_encode VARCHAR ( 1023 ) DEFAULT '' COMMENT '流程数据',
	flow_tree_json TINYTEXT COMMENT '流程树json',
	create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
	create_time datetime COMMENT '创建时间',
	update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
	update_time datetime COMMENT '更新时间',
PRIMARY KEY ( id )
) ENGINE = INNODB COMMENT = '构建流程';

DROP TABLE
IF
	EXISTS t_question_record;
CREATE TABLE t_question_record (
	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
	question VARCHAR ( 255 ) DEFAULT '' COMMENT '问题',
	result VARCHAR ( 511 ) DEFAULT '' COMMENT '结果',
	create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
	create_time datetime COMMENT '创建时间',
	update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
	update_time datetime COMMENT '更新时间',
PRIMARY KEY ( id )
) ENGINE = INNODB COMMENT = '问答查询记录';