Format sql
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
CREATE TYPE _NODE_TYPE AS ENUM ('junction', 'reservoir', 'tank');
|
||||
create type _node_type as enum ('junction', 'reservoir', 'tank');
|
||||
|
||||
CREATE TYPE _LINK_TYPE AS ENUM ('pipe', 'pump', 'valve');
|
||||
create type _link_type as enum ('pipe', 'pump', 'valve');
|
||||
|
||||
CREATE TABLE _NODE
|
||||
create table _node
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY
|
||||
, Type _NODE_TYPE NOT NULL
|
||||
id varchar(32) primary key
|
||||
, type _node_type not null
|
||||
);
|
||||
|
||||
CREATE TABLE _LINK
|
||||
create table _link
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY
|
||||
, Type _LINK_TYPE NOT NULL
|
||||
id varchar(32) primary key
|
||||
, type _link_type not null
|
||||
);
|
||||
|
||||
CREATE TABLE _CURVE
|
||||
create table _curve
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY
|
||||
id varchar(32) primary key
|
||||
);
|
||||
|
||||
CREATE TABLE _PATTERN
|
||||
create table _pattern
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY
|
||||
id varchar(32) primary key
|
||||
);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- [TITLE]
|
||||
|
||||
CREATE TABLE TITLE
|
||||
create table title
|
||||
(
|
||||
Value TEXT
|
||||
value text
|
||||
);
|
||||
|
||||
INSERT INTO TITLE (Value) VALUES ('');
|
||||
insert into title (value) values ('');
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
-- [STATUS]
|
||||
|
||||
CREATE TYPE STATUS_PIPE_PUMP_STATUS AS ENUM ('OPEN', 'CLOSED');
|
||||
create type status_pipe_pump_status as enum ('open', 'closed');
|
||||
|
||||
CREATE TABLE STATUS_PIPE
|
||||
create table status_pipe
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES PIPES(ID)
|
||||
, Status STATUS_PIPE_PUMP_STATUS NOT NULL
|
||||
id varchar(32) primary key references pipes(id)
|
||||
, status status_pipe_pump_status not null
|
||||
);
|
||||
|
||||
CREATE TABLE STATUS_PUMP
|
||||
create table status_pump
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES PUMPS(ID)
|
||||
, Status STATUS_PIPE_PUMP_STATUS NOT NULL
|
||||
id varchar(32) primary key references pumps(id)
|
||||
, status status_pipe_pump_status not null
|
||||
);
|
||||
|
||||
CREATE TYPE STATUS_VALVE_STATUS AS ENUM ('OPEN', 'CLOSED', 'ACTIVE');
|
||||
create type status_valve_status as enum ('open', 'closed', 'active');
|
||||
|
||||
CREATE TABLE STATUS_VALVE
|
||||
create table status_valve
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES VALVES(ID)
|
||||
, Status STATUS_VALVE_STATUS NOT NULL
|
||||
id varchar(32) primary key references valves(id)
|
||||
, status status_valve_status not null
|
||||
);
|
||||
|
||||
CREATE TABLE STATUS_LINK
|
||||
create table status_link
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
|
||||
, Setting NUMERIC NOT NULL
|
||||
id varchar(32) primary key references _link(id)
|
||||
, setting numeric not null
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- [PATTERNS]
|
||||
|
||||
CREATE TABLE PATTERNS
|
||||
create table patterns
|
||||
(
|
||||
ID VARCHAR(32) REFERENCES _PATTERN(ID) NOT NULL
|
||||
, Multipliers NUMERIC NOT NULL
|
||||
id varchar(32) references _pattern(id) not null
|
||||
, multipliers numeric not null
|
||||
);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- [CURVES]
|
||||
|
||||
CREATE TABLE CURVES
|
||||
create table curves
|
||||
(
|
||||
ID VARCHAR(32) REFERENCES _CURVE(ID) NOT NULL
|
||||
, X NUMERIC NOT NULL
|
||||
, Y NUMERIC NOT NULL
|
||||
id varchar(32) references _curve(id) not null
|
||||
, x numeric not null
|
||||
, y numeric not null
|
||||
);
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
-- [CONTROLS]
|
||||
|
||||
CREATE TYPE CONTROLS_1_PREP AS ENUM ('ABOVE', 'BELOW');
|
||||
create type controls_1_prep as enum ('above', 'below');
|
||||
|
||||
-- LINK linkID status IF NODE nodeID ABOVE / BELOW value
|
||||
CREATE TABLE CONTROLS_1
|
||||
create table controls_1
|
||||
(
|
||||
LinkID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
|
||||
, Status TEXT NOT NULL -- OPEN / CLOSED, a pump speed setting, or a control valve setting
|
||||
, NodeID VARCHAR(32) REFERENCES _NODE(ID) NOT NULL
|
||||
, Prep CONTROLS_1_PREP NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
linkid varchar(32) primary key references _link(id)
|
||||
, status text not null -- open / closed, a pump speed setting, or a control valve setting
|
||||
, nodeid varchar(32) references _node(id) not null
|
||||
, prep controls_1_prep not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
-- LINK linkID status AT TIME time
|
||||
CREATE TABLE CONTROLS_2
|
||||
create table controls_2
|
||||
(
|
||||
LinkID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
|
||||
, Status TEXT NOT NULL -- OPEN / CLOSED, a pump speed setting, or a control valve setting
|
||||
, Time INTERVAL HOUR
|
||||
linkid varchar(32) primary key references _link(id)
|
||||
, status text not null -- open / closed, a pump speed setting, or a control valve setting
|
||||
, time interval hour
|
||||
);
|
||||
|
||||
-- LINK linkID status AT CLOCKTIME clocktime AM / PM
|
||||
CREATE TABLE CONTROLS_3
|
||||
create table controls_3
|
||||
(
|
||||
LinkID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
|
||||
, Status TEXT NOT NULL -- OPEN / CLOSED, a pump speed setting, or a control valve setting
|
||||
, Clock_Time_Hour INTERVAL HOUR -- get AM/PM from it
|
||||
, Clock_Time_Min INTERVAL MINUTE
|
||||
linkid varchar(32) primary key references _link(id)
|
||||
, status text not null -- open / closed, a pump speed setting, or a control valve setting
|
||||
, clock_time_hour interval hour -- get am/pm from it
|
||||
, clock_time_min interval minute
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- [RULES]
|
||||
|
||||
CREATE TABLE RULES
|
||||
create table rules
|
||||
(
|
||||
Content TEXT PRIMARY KEY
|
||||
content text primary key
|
||||
);
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
-- [ENERGY]
|
||||
|
||||
CREATE TYPE ENERGY_PARAM AS ENUM ('PRICE', 'PATTERN', 'EFFIC');
|
||||
create type energy_param as enum ('price', 'pattern', 'effic');
|
||||
|
||||
-- GLOBAL PRICE / PATTERN / EFFIC value
|
||||
CREATE TABLE ENERGY_GLOBAL
|
||||
create table energy_global
|
||||
(
|
||||
Param ENERGY_PARAM NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
param energy_param not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
-- PUMP pumpID PRICE / PATTERN / EFFIC value
|
||||
CREATE TABLE ENERGY_PUMP
|
||||
create table energy_pump
|
||||
(
|
||||
ID VARCHAR(32) REFERENCES PUMPS(ID) NOT NULL
|
||||
, Param ENERGY_PARAM NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
id varchar(32) references pumps(id) not null
|
||||
, param energy_param not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
-- DEMAND CHARGE value
|
||||
CREATE TABLE ENERGY_DEMAND_CHARGE
|
||||
create table energy_demand_charge
|
||||
(
|
||||
Value NUMERIC NOT NULL
|
||||
value numeric not null
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- [EMITTERS]
|
||||
|
||||
CREATE TABLE EMITTERS
|
||||
create table emitters
|
||||
(
|
||||
Junction VARCHAR(32) PRIMARY KEY REFERENCES JUNCTIONS(ID)
|
||||
, Coefficient NUMERIC NOT NULL
|
||||
junction varchar(32) primary key references junctions(id)
|
||||
, coefficient numeric not null
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- [QUALITY]
|
||||
|
||||
CREATE TABLE QUALITY
|
||||
create table quality
|
||||
(
|
||||
Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, InitialQual NUMERIC NOT NULL
|
||||
node varchar(32) primary key references _node(id)
|
||||
, initialqual numeric not null
|
||||
);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
-- [SOURCES]
|
||||
|
||||
CREATE TYPE SOURCES_TYPE AS ENUM ('CONCEN', 'MASS', 'FLOWPACED', 'SETPOINT');
|
||||
create type sources_type as enum ('concen', 'mass', 'flowpaced', 'setpoint');
|
||||
|
||||
CREATE TABLE SOURCES
|
||||
create table sources
|
||||
(
|
||||
Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, Type SOURCES_TYPE NOT NULL
|
||||
, Strength NUMERIC NOT NULL
|
||||
, Time_Pattern VARCHAR(32) REFERENCES _PATTERN(ID)
|
||||
node varchar(32) primary key references _node(id)
|
||||
, type sources_type not null
|
||||
, strength numeric not null
|
||||
, time_pattern varchar(32) references _pattern(id)
|
||||
);
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
-- [REACTIONS]
|
||||
|
||||
CREATE TYPE REACTIONS_ORDER_PARAM AS ENUM ('BULK', 'WALL', 'TANK');
|
||||
create type reactions_order_param as enum ('bulk', 'wall', 'tank');
|
||||
|
||||
CREATE TABLE REACTIONS_ORDER
|
||||
create table reactions_order
|
||||
(
|
||||
Key REACTIONS_ORDER_PARAM NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
key reactions_order_param not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
CREATE TYPE REACTIONS_GLOBAL_PARAM AS ENUM ('BULK', 'WALL');
|
||||
create type reactions_global_param as enum ('bulk', 'wall');
|
||||
|
||||
CREATE TABLE REACTIONS_GLOBAL
|
||||
create table reactions_global
|
||||
(
|
||||
Key REACTIONS_GLOBAL_PARAM NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
key reactions_global_param not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
CREATE TYPE REACTIONS_PIPE_PARAM AS ENUM ('BULK', 'WALL');
|
||||
create type reactions_pipe_param as enum ('bulk', 'wall');
|
||||
|
||||
CREATE TABLE REACTIONS_PIPE
|
||||
create table reactions_pipe
|
||||
(
|
||||
Key REACTIONS_PIPE_PARAM NOT NULL
|
||||
, Pipe VARCHAR(32) REFERENCES PIPES(ID) NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
key reactions_pipe_param not null
|
||||
, pipe varchar(32) references pipes(id) not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
CREATE TABLE REACTIONS_TANK
|
||||
create table reactions_tank
|
||||
(
|
||||
Tank VARCHAR(32) REFERENCES TANKS(ID) NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
tank varchar(32) references tanks(id) not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
CREATE TABLE REACTIONS_LIMITING_POTENTIAL
|
||||
create table reactions_limiting_potential
|
||||
(
|
||||
Value NUMERIC NOT NULL
|
||||
value numeric not null
|
||||
);
|
||||
|
||||
CREATE TABLE REACTIONS_ROUGHNESS_CORRELATION
|
||||
create table reactions_roughness_correlation
|
||||
(
|
||||
Value NUMERIC NOT NULL
|
||||
value numeric not null
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [JUNCTIONS]
|
||||
|
||||
CREATE TABLE JUNCTIONS
|
||||
create table junctions
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, Elevation NUMERIC NOT NULL
|
||||
, Demand NUMERIC
|
||||
, Pattern VARCHAR(32) REFERENCES _PATTERN(ID)
|
||||
id varchar(32) primary key references _node(id)
|
||||
, elevation numeric not null
|
||||
, demand numeric
|
||||
, pattern varchar(32) references _pattern(id)
|
||||
);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
-- [MIXING]
|
||||
|
||||
CREATE TYPE MIXING_Model AS ENUM ('MIXED', '2COMP', 'FIFO', 'LIFO');
|
||||
create type mixing_model as enum ('mixed', '2comp', 'fifo', 'lifo');
|
||||
|
||||
CREATE TABLE MIXING
|
||||
create table mixing
|
||||
(
|
||||
Tank VARCHAR(32) PRIMARY KEY REFERENCES TANKS(ID)
|
||||
, Model MIXING_Model NOT NULL
|
||||
, Value NUMERIC
|
||||
tank varchar(32) primary key references tanks(id)
|
||||
, model mixing_model not null
|
||||
, value numeric
|
||||
);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
-- TODO: constraint
|
||||
|
||||
CREATE TABLE TIMES
|
||||
create table times
|
||||
(
|
||||
Key TEXT NOT NULL
|
||||
, Value TEXT NOT NULL
|
||||
key text not null
|
||||
, value text not null
|
||||
);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
-- TODO: constraint
|
||||
|
||||
CREATE TABLE REPORT
|
||||
create table report
|
||||
(
|
||||
Key TEXT NOT NULL
|
||||
, Value TEXT NOT NULL
|
||||
key text not null
|
||||
, value text not null
|
||||
);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
-- TODO: constraint
|
||||
|
||||
CREATE TABLE OPTIONS
|
||||
create table options
|
||||
(
|
||||
Key TEXT NOT NULL
|
||||
, Value TEXT NOT NULL
|
||||
key text not null
|
||||
, value text not null
|
||||
);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
-- [COORDINATES]
|
||||
|
||||
CREATE TABLE COORDINATES
|
||||
create table coordinates
|
||||
(
|
||||
Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, Coord POINT NOT NULL
|
||||
node varchar(32) primary key references _node(id)
|
||||
, coord point not null
|
||||
);
|
||||
|
||||
CREATE INDEX COORDINATES_SPGIST ON COORDINATES USING SPGIST(Coord);
|
||||
CREATE INDEX COORDINATES_GIST ON COORDINATES USING GIST(Coord);
|
||||
create index coordinates_spgist on coordinates using spgist(coord);
|
||||
create index coordinates_gist on coordinates using gist(coord);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- [VERTICES]
|
||||
|
||||
CREATE TABLE VERTICES
|
||||
create table vertices
|
||||
(
|
||||
Link VARCHAR(32) REFERENCES _LINK(ID) NOT NULL
|
||||
, X NUMERIC NOT NULL
|
||||
, Y NUMERIC NOT NULL
|
||||
link varchar(32) references _link(id) not null
|
||||
, x numeric not null
|
||||
, y numeric not null
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [LABELS]
|
||||
|
||||
CREATE TABLE LABELS
|
||||
create table labels
|
||||
(
|
||||
X NUMERIC NOT NULL
|
||||
, Y NUMERIC NOT NULL
|
||||
, Label TEXT NOT NULL
|
||||
, AnchorNode VARCHAR(32) REFERENCES _NODE(ID)
|
||||
x numeric not null
|
||||
, y numeric not null
|
||||
, label text not null
|
||||
, anchornode varchar(32) references _node(id)
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- [BACKDROP]
|
||||
|
||||
CREATE TABLE BACKDROP
|
||||
create table backdrop
|
||||
(
|
||||
Content TEXT PRIMARY KEY
|
||||
content text primary key
|
||||
);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- [RESERVOIRS]
|
||||
|
||||
CREATE TABLE RESERVOIRS
|
||||
create table reservoirs
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, Head NUMERIC NOT NULL
|
||||
, Pattern VARCHAR(32) REFERENCES _PATTERN(ID)
|
||||
id varchar(32) primary key references _node(id)
|
||||
, head numeric not null
|
||||
, pattern varchar(32) references _pattern(id)
|
||||
);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
-- [TANKS]
|
||||
|
||||
CREATE TYPE TANKS_OVERFLOW AS ENUM ('yes', 'no');
|
||||
create type tanks_overflow as enum ('yes', 'no');
|
||||
|
||||
CREATE TABLE TANKS
|
||||
create table tanks
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, Elevation NUMERIC NOT NULL
|
||||
, Init_Level NUMERIC NOT NULL
|
||||
, Min_Level NUMERIC NOT NULL
|
||||
, Max_Level NUMERIC NOT NULL
|
||||
, Diameter NUMERIC NOT NULL
|
||||
, Min_Vol NUMERIC NOT NULL
|
||||
, Vol_Curve VARCHAR(32) REFERENCES _CURVE(ID)
|
||||
, Overflow TANKS_OVERFLOW
|
||||
id varchar(32) primary key references _node(id)
|
||||
, elevation numeric not null
|
||||
, init_level numeric not null
|
||||
, min_level numeric not null
|
||||
, max_level numeric not null
|
||||
, diameter numeric not null
|
||||
, min_vol numeric not null
|
||||
, vol_curve varchar(32) references _curve(id)
|
||||
, overflow tanks_overflow
|
||||
);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
-- [PIPES]
|
||||
|
||||
CREATE TYPE PIPES_STATUS AS ENUM ('open', 'closed', 'cv');
|
||||
create type pipes_status as enum ('open', 'closed', 'cv');
|
||||
|
||||
CREATE TABLE PIPES
|
||||
create table pipes
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
|
||||
, Node1 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL
|
||||
, Node2 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL
|
||||
, Length NUMERIC NOT NULL
|
||||
, Diameter NUMERIC NOT NULL
|
||||
, Roughness NUMERIC NOT NULL
|
||||
, Minor_Loss NUMERIC NOT NULL
|
||||
, Status PIPES_STATUS NOT NULL
|
||||
id varchar(32) primary key references _link(id)
|
||||
, node1 varchar(32) references _node(id) not null
|
||||
, node2 varchar(32) references _node(id) not null
|
||||
, length numeric not null
|
||||
, diameter numeric not null
|
||||
, roughness numeric not null
|
||||
, minor_loss numeric not null
|
||||
, status pipes_status not null
|
||||
);
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
-- [PUMPS]
|
||||
|
||||
CREATE TABLE PUMPS
|
||||
create table pumps
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
|
||||
, Node1 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL
|
||||
, Node2 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL
|
||||
id varchar(32) primary key references _link(id)
|
||||
, node1 varchar(32) references _node(id) not null
|
||||
, node2 varchar(32) references _node(id) not null
|
||||
);
|
||||
|
||||
CREATE TABLE PUMPS_PROPERTY_POWER
|
||||
create table pumps_property_power
|
||||
(
|
||||
ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID)
|
||||
, Value VARCHAR(32) NOT NULL
|
||||
id varchar primary key references pumps(id)
|
||||
, value varchar(32) not null
|
||||
);
|
||||
|
||||
CREATE TABLE PUMPS_PROPERTY_SPEED
|
||||
create table pumps_property_speed
|
||||
(
|
||||
ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID)
|
||||
, Value VARCHAR(32) NOT NULL
|
||||
id varchar primary key references pumps(id)
|
||||
, value varchar(32) not null
|
||||
);
|
||||
|
||||
CREATE TABLE PUMPS_PROPERTY_HEAD
|
||||
create table pumps_property_head
|
||||
(
|
||||
ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID)
|
||||
, Head VARCHAR(32) REFERENCES _CURVE(ID) NOT NULL
|
||||
id varchar primary key references pumps(id)
|
||||
, head varchar(32) references _curve(id) not null
|
||||
);
|
||||
|
||||
CREATE TABLE PUMPS_PROPERTY_PATTERN
|
||||
create table pumps_property_pattern
|
||||
(
|
||||
ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID)
|
||||
, Pattern VARCHAR(32) REFERENCES _PATTERN(ID) NOT NULL
|
||||
id varchar primary key references pumps(id)
|
||||
, pattern varchar(32) references _pattern(id) not null
|
||||
);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
-- [VALVES]
|
||||
|
||||
CREATE TYPE VALVES_TYPE AS ENUM ('prv', 'psv', 'pbv', 'fcv', 'tcv', 'gpv');
|
||||
create type valves_type as enum ('prv', 'psv', 'pbv', 'fcv', 'tcv', 'gpv');
|
||||
|
||||
CREATE TABLE VALVES
|
||||
create table valves
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
|
||||
, Node1 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL
|
||||
, Node2 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL
|
||||
, Diameter NUMERIC NOT NULL
|
||||
, Type VALVES_TYPE NOT NULL
|
||||
, Setting NUMERIC NOT NULL
|
||||
, Minor_Loss NUMERIC NOT NULL
|
||||
id varchar(32) primary key references _link(id)
|
||||
, node1 varchar(32) references _node(id) not null
|
||||
, node2 varchar(32) references _node(id) not null
|
||||
, diameter numeric not null
|
||||
, type valves_type not null
|
||||
, setting numeric not null
|
||||
, minor_loss numeric not null
|
||||
);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
-- [TAGS]
|
||||
|
||||
CREATE TABLE TAGS_NODE
|
||||
create table tags_node
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, Tag TEXT NOT NULL
|
||||
id varchar(32) primary key references _node(id)
|
||||
, tag text not null
|
||||
);
|
||||
|
||||
CREATE TABLE TAGS_LINK
|
||||
create table tags_link
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
|
||||
, Tag TEXT NOT NULL
|
||||
id varchar(32) primary key references _link(id)
|
||||
, tag text not null
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [DEMANDS]
|
||||
|
||||
CREATE TABLE DEMANDS
|
||||
create table demands
|
||||
(
|
||||
Junction VARCHAR(32) REFERENCES JUNCTIONS(ID) NOT NULL
|
||||
, Demand NUMERIC NOT NULL
|
||||
, Pattern VARCHAR(32) REFERENCES _PATTERN(ID)
|
||||
, Category TEXT NOT NULL
|
||||
junction varchar(32) references junctions(id) not null
|
||||
, demand numeric not null
|
||||
, pattern varchar(32) references _pattern(id)
|
||||
, category text not null
|
||||
);
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
CREATE TYPE API_OPERATION AS ENUM ('init', 'add', 'delete', 'update');
|
||||
create type api_operation as enum ('init', 'add', 'delete', 'update');
|
||||
|
||||
CREATE TABLE OPERATION
|
||||
create table operation
|
||||
(
|
||||
ID SERIAL PRIMARY KEY
|
||||
, Redo TEXT NOT NULL
|
||||
, Undo TEXT NOT NULL
|
||||
, Parent INTEGER REFERENCES OPERATION(ID)
|
||||
, Redo_Child INTEGER REFERENCES OPERATION(ID)
|
||||
, Api_Id TEXT NOT NULL
|
||||
, Api_Op API_OPERATION NOT NULL
|
||||
, Api_Object_Type TEXT NOT NULL
|
||||
, Api_Object_Id TEXT NOT NULL
|
||||
, Api_Object_Properties TEXT[]
|
||||
id serial primary key
|
||||
, redo text not null
|
||||
, undo text not null
|
||||
, parent integer references operation(id)
|
||||
, redo_child integer references operation(id)
|
||||
, api_id text not null
|
||||
, api_op api_operation not null
|
||||
, api_object_type text not null
|
||||
, api_object_id text not null
|
||||
, api_object_properties text[]
|
||||
);
|
||||
|
||||
INSERT INTO OPERATION (ID, Redo, Undo, Api_Id, Api_Op, Api_Object_Type, Api_Object_Id) VALUES (0, '', '', '', 'init', '', '');
|
||||
insert into operation (id, redo, undo, api_id, api_op, api_object_type, api_object_id) values (0, '', '', '', 'init', '', '');
|
||||
|
||||
CREATE TABLE CURRENT_OPERATION
|
||||
create table current_operation
|
||||
(
|
||||
ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID)
|
||||
id integer primary key references operation(id)
|
||||
);
|
||||
|
||||
INSERT INTO CURRENT_OPERATION (ID) VALUES (0);
|
||||
insert into current_operation (id) values (0);
|
||||
|
||||
CREATE TABLE SNAPSHOT_OPERATION
|
||||
create table snapshot_operation
|
||||
(
|
||||
ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID)
|
||||
, Tag TEXT NOT NULL UNIQUE
|
||||
id integer primary key references operation(id)
|
||||
, tag text not null unique
|
||||
);
|
||||
|
||||
CREATE TABLE TRANSACTION_OPERATION
|
||||
create table transaction_operation
|
||||
(
|
||||
ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID)
|
||||
, STRICT BOOLEAN NOT NULL DEFAULT FALSE
|
||||
id integer primary key references operation(id)
|
||||
, strict boolean not null default false
|
||||
);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
DROP TABLE IF EXISTS _PATTERN;
|
||||
drop table if exists _pattern;
|
||||
|
||||
DROP TABLE IF EXISTS _CURVE;
|
||||
drop table if exists _curve;
|
||||
|
||||
DROP TABLE IF EXISTS _LINK;
|
||||
drop table if exists _link;
|
||||
|
||||
DROP TABLE IF EXISTS _NODE;
|
||||
drop table if exists _node;
|
||||
|
||||
DROP TYPE IF EXISTS _LINK_TYPE;
|
||||
drop type if exists _link_type;
|
||||
|
||||
DROP TYPE IF EXISTS _NODE_TYPE;
|
||||
drop type if exists _node_type;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [TITLE]
|
||||
|
||||
DROP TABLE IF EXISTS TITLE;
|
||||
drop table if exists title;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
-- [STATUS]
|
||||
|
||||
DROP TABLE IF EXISTS STATUS_LINK;
|
||||
drop table if exists status_link;
|
||||
|
||||
DROP TABLE IF EXISTS STATUS_VALVE;
|
||||
drop table if exists status_valve;
|
||||
|
||||
DROP TYPE IF EXISTS STATUS_VALVE_STATUS;
|
||||
drop type if exists status_valve_status;
|
||||
|
||||
DROP TABLE IF EXISTS STATUS_PUMP;
|
||||
drop table if exists status_pump;
|
||||
|
||||
DROP TABLE IF EXISTS STATUS_PIPE;
|
||||
drop table if exists status_pipe;
|
||||
|
||||
DROP TYPE IF EXISTS STATUS_PIPE_PUMP_STATUS;
|
||||
drop type if exists status_pipe_pump_status;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [PATTERNS]
|
||||
|
||||
DROP TABLE IF EXISTS PATTERNS;
|
||||
drop table if exists patterns;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [CURVES]
|
||||
|
||||
DROP TABLE IF EXISTS CURVES;
|
||||
drop table if exists curves;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [CONTROLS]
|
||||
|
||||
DROP TABLE IF EXISTS CONTROLS_3;
|
||||
drop table if exists controls_3;
|
||||
|
||||
DROP TABLE IF EXISTS CONTROLS_2;
|
||||
drop table if exists controls_2;
|
||||
|
||||
DROP TABLE IF EXISTS CONTROLS_1;
|
||||
drop table if exists controls_1;
|
||||
|
||||
DROP TYPE IF EXISTS CONTROLS_1_PREP;
|
||||
drop type if exists controls_1_prep;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [RULES]
|
||||
|
||||
DROP TABLE IF EXISTS RULES;
|
||||
drop table if exists rules;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [ENERGY]
|
||||
|
||||
DROP TABLE IF EXISTS ENERGY_DEMAND_CHARGE;
|
||||
drop table if exists energy_demand_charge;
|
||||
|
||||
DROP TABLE IF EXISTS ENERGY_PUMP;
|
||||
drop table if exists energy_pump;
|
||||
|
||||
DROP TABLE IF EXISTS ENERGY_GLOBAL;
|
||||
drop table if exists energy_global;
|
||||
|
||||
DROP TYPE IF EXISTS ENERGY_PARAM;
|
||||
drop type if exists energy_param;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [EMITTERS]
|
||||
|
||||
DROP TABLE IF EXISTS EMITTERS;
|
||||
drop table if exists emitters;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [QUALITY]
|
||||
|
||||
DROP TABLE IF EXISTS QUALITY;
|
||||
drop table if exists quality;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [SOURCES]
|
||||
|
||||
DROP TABLE IF EXISTS SOURCES;
|
||||
drop table if exists sources;
|
||||
|
||||
DROP TYPE IF EXISTS SOURCES_TYPE;
|
||||
drop type if exists sources_type;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
-- [REACTIONS]
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_ROUGHNESS_CORRELATION;
|
||||
drop table if exists reactions_roughness_correlation;
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_LIMITING_POTENTIAL;
|
||||
drop table if exists reactions_limiting_potential;
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_TANK;
|
||||
drop table if exists reactions_tank;
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_PIPE;
|
||||
drop table if exists reactions_pipe;
|
||||
|
||||
DROP TYPE IF EXISTS REACTIONS_PIPE_PARAM;
|
||||
drop type if exists reactions_pipe_param;
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_GLOBAL;
|
||||
drop table if exists reactions_global;
|
||||
|
||||
DROP TYPE IF EXISTS REACTIONS_GLOBAL_PARAM;
|
||||
drop type if exists reactions_global_param;
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_ORDER;
|
||||
drop table if exists reactions_order;
|
||||
|
||||
DROP TYPE IF EXISTS REACTIONS_ORDER_PARAM;
|
||||
drop type if exists reactions_order_param;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [JUNCTIONS]
|
||||
|
||||
DROP TABLE IF EXISTS JUNCTIONS;
|
||||
drop table if exists junctions;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [MIXING]
|
||||
|
||||
DROP TABLE IF EXISTS MIXING;
|
||||
drop table if exists mixing;
|
||||
|
||||
DROP TYPE IF EXISTS MIXING_Model;
|
||||
drop type if exists mixing_model;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [TIMES]
|
||||
|
||||
DROP TABLE IF EXISTS TIMES;
|
||||
drop table if exists times;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [REPORT]
|
||||
|
||||
DROP TABLE IF EXISTS REPORT;
|
||||
drop table if exists report;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [OPTIONS]
|
||||
|
||||
DROP TABLE IF EXISTS OPTIONS;
|
||||
drop table if exists options;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- [COORDINATES]
|
||||
|
||||
DROP INDEX IF EXISTS COORDINATES_GIST;
|
||||
drop index if exists coordinates_gist;
|
||||
|
||||
DROP INDEX IF EXISTS COORDINATES_SPGIST;
|
||||
drop index if exists coordinates_spgist;
|
||||
|
||||
DROP TABLE IF EXISTS COORDINATES;
|
||||
drop table if exists coordinates;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [VERTICES]
|
||||
|
||||
DROP TABLE IF EXISTS VERTICES;
|
||||
drop table if exists vertices;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [LABELS]
|
||||
|
||||
DROP TABLE IF EXISTS LABELS;
|
||||
drop table if exists labels;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [BACKDROP]
|
||||
|
||||
DROP TABLE IF EXISTS BACKDROP;
|
||||
drop table if exists backdrop;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [RESERVOIRS]
|
||||
|
||||
DROP TABLE IF EXISTS RESERVOIRS;
|
||||
drop table if exists reservoirs;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [TANKS]
|
||||
|
||||
DROP TABLE IF EXISTS TANKS;
|
||||
drop table if exists tanks;
|
||||
|
||||
DROP TYPE IF EXISTS TANKS_OVERFLOW;
|
||||
drop type if exists tanks_overflow;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [PIPES]
|
||||
|
||||
DROP TABLE IF EXISTS PIPES;
|
||||
drop table if exists pipes;
|
||||
|
||||
DROP TYPE IF EXISTS PIPES_STATUS;
|
||||
drop type if exists pipes_status;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
-- [PUMPS]
|
||||
|
||||
DROP TABLE IF EXISTS PUMPS_PROPERTY_PATTERN;
|
||||
drop table if exists pumps_property_pattern;
|
||||
|
||||
DROP TABLE IF EXISTS PUMPS_PROPERTY_HEAD;
|
||||
drop table if exists pumps_property_head;
|
||||
|
||||
DROP TABLE IF EXISTS PUMPS_PROPERTY_SPEED;
|
||||
drop table if exists pumps_property_speed;
|
||||
|
||||
DROP TABLE IF EXISTS PUMPS_PROPERTY_POWER;
|
||||
drop table if exists pumps_property_power;
|
||||
|
||||
DROP TABLE IF EXISTS PUMPS;
|
||||
drop table if exists pumps;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [VALVES]
|
||||
|
||||
DROP TABLE IF EXISTS VALVES;
|
||||
drop table if exists valves;
|
||||
|
||||
DROP TYPE IF EXISTS VALVES_TYPE;
|
||||
drop type if exists valves_type;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [TAGS]
|
||||
|
||||
DROP TABLE IF EXISTS TAGS_LINK;
|
||||
drop table if exists tags_link;
|
||||
|
||||
DROP TABLE IF EXISTS TAGS_NODE;
|
||||
drop table if exists tags_node;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [DEMANDS]
|
||||
|
||||
DROP TABLE IF EXISTS DEMANDS;
|
||||
drop table if exists demands;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
DROP TABLE IF EXISTS TRANSACTION_OPERATION;
|
||||
drop table if exists transaction_operation;
|
||||
|
||||
DROP TABLE IF EXISTS SNAPSHOT_OPERATION;
|
||||
drop table if exists snapshot_operation;
|
||||
|
||||
DROP TABLE IF EXISTS CURRENT_OPERATION;
|
||||
drop table if exists current_operation;
|
||||
|
||||
DROP TABLE IF EXISTS OPERATION;
|
||||
drop table if exists operation;
|
||||
|
||||
DROP TYPE IF EXISTS API_OPERATION;
|
||||
drop type if exists api_operation;
|
||||
|
||||
Reference in New Issue
Block a user