szr-indicator-service/common/src/main/resources/zbsz.sql

105 lines
5.0 KiB
MySQL
Raw Normal View History

2024-02-25 23:27:26 +08:00
--generated always 1
--_指标类型
drop table if exists indicator_dic;
create table indicator_dic (
id int4 generated always as identity primary key,
indicator_type varchar(128) not null,
parent_id int4,
create_time timestamp not null,
update_time timestamp
);
comment on column indicator_dic.id is '主键';
comment on column indicator_dic.indicator_type is '类型';
comment on column indicator_dic.parent_id is '父级ID';
comment on column indicator_dic.create_time is '创建时间';
comment on column indicator_dic.update_time is '修改时间';
insert into indicator_dic(indicator_type,create_time,update_time) values ('基础指标',current_timestamp,current_timestamp);
insert into indicator_dic(indicator_type,create_time,update_time) values ('逻辑指标',current_timestamp,current_timestamp);
insert into indicator_dic(indicator_type,create_time,update_time) values ('统计指标',current_timestamp,current_timestamp);
--_应用类型
drop table if exists app_dic;
create table app_dic (
id int4 generated always as identity primary key,
app_type varchar(128) not null,
parent_id int4,
create_time timestamp not null,
update_time timestamp
);
comment on column app_dic.id is '主键';
comment on column app_dic.app_type is '类型';
comment on column app_dic.parent_id is '父级ID';
comment on column app_dic.create_time is '创建时间';
comment on column app_dic.update_time is '修改时间';
insert into app_dic(app_type,create_time,update_time) values ('态势感知',current_timestamp,current_timestamp);
insert into app_dic(app_type,create_time,update_time) values ('智能战果分析',current_timestamp,current_timestamp);
insert into app_dic(app_type,parent_id,create_time,update_time) values ('风险人',1,current_timestamp,current_timestamp);
insert into app_dic(app_type,parent_id,create_time,update_time) values ('风险事',1,current_timestamp,current_timestamp);
insert into app_dic(app_type,parent_id,create_time,update_time) values ('风险物',1,current_timestamp,current_timestamp);
insert into app_dic(app_type,parent_id,create_time,update_time) values ('',2,current_timestamp,current_timestamp);
insert into app_dic(app_type,parent_id,create_time,update_time) values ('',2,current_timestamp,current_timestamp);
insert into app_dic(app_type,parent_id,create_time,update_time) values ('',2,current_timestamp,current_timestamp);
--_指标
drop table if exists p_indicator;
create table p_indicator (
id int4 generated always as identity primary key,
dynamic_table varchar(128) not null,
dynamic_column varchar(128) not null,
scene_id int4,
indicator_dic_id int4,
app_dic_p_id int4,
app_dic_c_id int4,
search_table varchar(255),
search_column varchar(255),
indicator_code varchar(128),
create_time timestamp not null,
update_time timestamp
);
comment on column p_indicator.id is '指标编号';
comment on column p_indicator.dynamic_table is '动态表名称';
comment on column p_indicator.dynamic_column is '动态表字段英文名称';
comment on column p_indicator.scene_id is '关联技能';
comment on column p_indicator.indicator_dic_id is '指标类型';
comment on column p_indicator.app_dic_p_id is '关联应用模块';
comment on column p_indicator.app_dic_c_id is '关联功能';
comment on column p_indicator.search_table is '关联表名称';
comment on column p_indicator.search_column is '关联表字段名称';
comment on column p_indicator.indicator_code is '代码值';
comment on column p_indicator.create_time is '创建时间';
comment on column p_indicator.update_time is '修改时间';
--_指标_标签
drop table if exists p_indicator_label;
create table p_indicator_label (
id int4 generated always as identity primary key,
table_name varchar(128) not null,
label_name varchar(128) not null,
label_level int4 not null,
parent_id int4,
column_name varchar(128),
create_time timestamp not null,
update_time timestamp
);
comment on column p_indicator_label.id is '标签ID';
comment on column p_indicator_label.table_name is '表名称';
comment on column p_indicator_label.label_name is '标签名称';
comment on column p_indicator_label.label_level is '标签等级';
comment on column p_indicator_label.parent_id is '父级ID';
comment on column p_indicator_label.column_name is '字段名称';
comment on column p_indicator_label.create_time is '创建时间';
comment on column p_indicator_label.update_time is '修改时间';
--_指标_标签_中间表
drop table if exists p_indicator_label_tmp;
create table p_indicator_label_tmp (
id int4 generated always as identity primary key,
indicator_id int4,
label_id int4,
create_time timestamp not null,
update_time timestamp
);
comment on column p_indicator_label_tmp.id is '标签ID';
comment on column p_indicator_label_tmp.indicator_id is '指标ID';
comment on column p_indicator_label_tmp.label_id is '标签id';
comment on column p_indicator_label_tmp.create_time is '创建时间';
comment on column p_indicator_label_tmp.update_time is '修改时间';