Put all table & enum into namespace(postgres schema) 'tj'
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
create type tj.node_type as enum ('junction', 'reservoir', 'tank');
|
||||
create type tj.node_type as enum
|
||||
(
|
||||
'junction'
|
||||
, 'reservoir'
|
||||
, 'tank'
|
||||
);
|
||||
|
||||
create type tj.link_type as enum ('pipe', 'pump', 'valve');
|
||||
create type tj.link_type as enum
|
||||
(
|
||||
'pipe'
|
||||
, 'pump'
|
||||
, 'valve'
|
||||
);
|
||||
|
||||
create table tj.node
|
||||
(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- [TITLE]
|
||||
-- [title]
|
||||
|
||||
CREATE TABLE TITLE
|
||||
create table tj.title
|
||||
(
|
||||
Value TEXT
|
||||
value text
|
||||
);
|
||||
|
||||
INSERT INTO TITLE (Value) VALUES ('');
|
||||
insert into tj.title (value) values ('');
|
||||
|
||||
@@ -1,29 +1,33 @@
|
||||
-- [STATUS]
|
||||
-- [status]
|
||||
|
||||
CREATE TYPE STATUS_PIPE_PUMP_STATUS AS ENUM ('OPEN', 'CLOSED');
|
||||
|
||||
CREATE TABLE STATUS_PIPE
|
||||
create type tj.status_pipe_pump_status as enum
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES PIPES(ID)
|
||||
, Status STATUS_PIPE_PUMP_STATUS NOT NULL
|
||||
'open'
|
||||
, 'closed'
|
||||
);
|
||||
|
||||
CREATE TABLE STATUS_PUMP
|
||||
create table tj.status_pipe
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES PUMPS(ID)
|
||||
, Status STATUS_PIPE_PUMP_STATUS NOT NULL
|
||||
id varchar(32) primary key references tj.pipes(id)
|
||||
, status tj.status_pipe_pump_status not null
|
||||
);
|
||||
|
||||
CREATE TYPE STATUS_VALVE_STATUS AS ENUM ('OPEN', 'CLOSED', 'ACTIVE');
|
||||
|
||||
CREATE TABLE STATUS_VALVE
|
||||
create table tj.status_pump
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES VALVES(ID)
|
||||
, Status STATUS_VALVE_STATUS NOT NULL
|
||||
id varchar(32) primary key references tj.pumps(id)
|
||||
, status tj.status_pipe_pump_status not null
|
||||
);
|
||||
|
||||
CREATE TABLE STATUS_LINK
|
||||
create type tj.status_valve_status as enum ('open', 'closed', 'active');
|
||||
|
||||
create table tj.status_valve
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
|
||||
, Setting NUMERIC NOT NULL
|
||||
id varchar(32) primary key references tj.valves(id)
|
||||
, status tj.status_valve_status not null
|
||||
);
|
||||
|
||||
create table tj.status_link
|
||||
(
|
||||
id varchar(32) primary key references tj.link(id)
|
||||
, setting numeric not null
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- [PATTERNS]
|
||||
-- [patterns]
|
||||
|
||||
CREATE TABLE PATTERNS
|
||||
create table tj.patterns
|
||||
(
|
||||
ID VARCHAR(32) REFERENCES _PATTERN(ID) NOT NULL
|
||||
, Multipliers NUMERIC NOT NULL
|
||||
id varchar(32) references tj.pattern(id) not null
|
||||
, multipliers numeric not null
|
||||
);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- [CURVES]
|
||||
-- [curves]
|
||||
|
||||
CREATE TABLE CURVES
|
||||
create table tj.curves
|
||||
(
|
||||
ID VARCHAR(32) REFERENCES _CURVE(ID) NOT NULL
|
||||
, X NUMERIC NOT NULL
|
||||
, Y NUMERIC NOT NULL
|
||||
id varchar(32) references tj.curve(id) not null
|
||||
, x numeric not null
|
||||
, y numeric not null
|
||||
);
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
-- [CONTROLS]
|
||||
-- [controls]
|
||||
|
||||
CREATE TYPE CONTROLS_1_PREP AS ENUM ('ABOVE', 'BELOW');
|
||||
create type tj.controls_1_prep as enum ('above', 'below');
|
||||
|
||||
-- LINK linkID status IF NODE nodeID ABOVE / BELOW value
|
||||
CREATE TABLE CONTROLS_1
|
||||
-- link linkid status if node nodeid above / below value
|
||||
create table tj.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 tj.link(id)
|
||||
, status text not null -- open / closed, a pump speed setting, or a control valve setting
|
||||
, nodeid varchar(32) references tj.node(id) not null
|
||||
, prep tj.controls_1_prep not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
-- LINK linkID status AT TIME time
|
||||
CREATE TABLE CONTROLS_2
|
||||
-- link linkid status at time time
|
||||
create table tj.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 tj.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
|
||||
-- link linkid status at clocktime clocktime am / pm
|
||||
create table tj.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
|
||||
, ClockTimeHour INTERVAL HOUR -- get AM/PM from it
|
||||
, ClockTimeMin INTERVAL MINUTE
|
||||
linkid varchar(32) primary key references tj.link(id)
|
||||
, status text not null -- open / closed, a pump speed setting, or a control valve setting
|
||||
, clocktimehour interval hour -- get am/pm from it
|
||||
, clocktimemin interval minute
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- [RULES]
|
||||
-- [rules]
|
||||
|
||||
CREATE TABLE RULES
|
||||
create table tj.rules
|
||||
(
|
||||
Content TEXT PRIMARY KEY
|
||||
content text primary key
|
||||
);
|
||||
|
||||
@@ -1,24 +1,29 @@
|
||||
-- [ENERGY]
|
||||
-- [energy]
|
||||
|
||||
CREATE TYPE ENERGY_PARAM AS ENUM ('PRICE', 'PATTERN', 'EFFIC');
|
||||
|
||||
-- GLOBAL PRICE / PATTERN / EFFIC value
|
||||
CREATE TABLE ENERGY_GLOBAL
|
||||
create type tj.energy_param as enum
|
||||
(
|
||||
Param ENERGY_PARAM NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
'price'
|
||||
, 'pattern'
|
||||
, 'effic'
|
||||
);
|
||||
|
||||
-- PUMP pumpID PRICE / PATTERN / EFFIC value
|
||||
CREATE TABLE ENERGY_PUMP
|
||||
-- global price / pattern / effic value
|
||||
create table tj.energy_global
|
||||
(
|
||||
ID VARCHAR(32) REFERENCES PUMPS(ID) NOT NULL
|
||||
, Param ENERGY_PARAM NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
param tj.energy_param not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
-- DEMAND CHARGE value
|
||||
CREATE TABLE ENERGY_DEMAND_CHARGE
|
||||
-- pump pumpid price / pattern / effic value
|
||||
create table tj.energy_pump
|
||||
(
|
||||
Value NUMERIC NOT NULL
|
||||
id varchar(32) references tj.pumps(id) not null
|
||||
, param tj.energy_param not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
-- demand charge value
|
||||
create table tj.energy_demand_charge
|
||||
(
|
||||
value numeric not null
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- [EMITTERS]
|
||||
-- [emitters]
|
||||
|
||||
CREATE TABLE EMITTERS
|
||||
create table tj.emitters
|
||||
(
|
||||
Junction VARCHAR(32) PRIMARY KEY REFERENCES JUNCTIONS(ID)
|
||||
, Coefficient NUMERIC NOT NULL
|
||||
junction varchar(32) primary key references tj.junctions(id)
|
||||
, coefficient numeric not null
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- [QUALITY]
|
||||
-- [quality]
|
||||
|
||||
CREATE TABLE QUALITY
|
||||
create table tj.quality
|
||||
(
|
||||
Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, InitialQual NUMERIC NOT NULL
|
||||
node varchar(32) primary key references tj.node(id)
|
||||
, initialqual numeric not null
|
||||
);
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
-- [SOURCES]
|
||||
-- [sources]
|
||||
|
||||
CREATE TYPE SOURCES_TYPE AS ENUM ('CONCEN', 'MASS', 'FLOWPACED', 'SETPOINT');
|
||||
|
||||
CREATE TABLE SOURCES
|
||||
create type tj.sources_type as enum
|
||||
(
|
||||
Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, Type SOURCES_TYPE NOT NULL
|
||||
, Strength NUMERIC NOT NULL
|
||||
, TimePattern VARCHAR(32) REFERENCES _PATTERN(ID)
|
||||
'concen'
|
||||
, 'mass'
|
||||
, 'flowpaced'
|
||||
, 'setpoint'
|
||||
);
|
||||
|
||||
create table tj.sources
|
||||
(
|
||||
node varchar(32) primary key references tj.node(id)
|
||||
, type tj.sources_type not null
|
||||
, strength numeric not null
|
||||
, timepattern varchar(32) references tj.pattern(id)
|
||||
);
|
||||
|
||||
@@ -1,42 +1,55 @@
|
||||
-- [REACTIONS]
|
||||
-- [reactions]
|
||||
|
||||
CREATE TYPE REACTIONS_ORDER_PARAM AS ENUM ('BULK', 'WALL', 'TANK');
|
||||
|
||||
CREATE TABLE REACTIONS_ORDER
|
||||
create type tj.reactions_order_param as enum
|
||||
(
|
||||
Key REACTIONS_ORDER_PARAM NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
'bulk'
|
||||
, 'wall'
|
||||
, 'tank'
|
||||
);
|
||||
|
||||
CREATE TYPE REACTIONS_GLOBAL_PARAM AS ENUM ('BULK', 'WALL');
|
||||
|
||||
CREATE TABLE REACTIONS_GLOBAL
|
||||
create table tj.reactions_order
|
||||
(
|
||||
Key REACTIONS_GLOBAL_PARAM NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
key tj.reactions_order_param not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
CREATE TYPE REACTIONS_PIPE_PARAM AS ENUM ('BULK', 'WALL');
|
||||
|
||||
CREATE TABLE REACTIONS_PIPE
|
||||
create type tj.reactions_global_param as enum
|
||||
(
|
||||
Key REACTIONS_PIPE_PARAM NOT NULL
|
||||
, Pipe VARCHAR(32) REFERENCES PIPES(ID) NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
'bulk'
|
||||
, 'wall'
|
||||
);
|
||||
|
||||
CREATE TABLE REACTIONS_TANK
|
||||
create table tj.reactions_global
|
||||
(
|
||||
Tank VARCHAR(32) REFERENCES TANKS(ID) NOT NULL
|
||||
, Value NUMERIC NOT NULL
|
||||
key tj.reactions_global_param not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
CREATE TABLE REACTIONS_LIMITING_POTENTIAL
|
||||
create type tj.reactions_pipe_param as enum
|
||||
(
|
||||
Value NUMERIC NOT NULL
|
||||
'bulk'
|
||||
, 'wall'
|
||||
);
|
||||
|
||||
CREATE TABLE REACTIONS_ROUGHNESS_CORRELATION
|
||||
create table tj.reactions_pipe
|
||||
(
|
||||
Value NUMERIC NOT NULL
|
||||
key tj.reactions_pipe_param not null
|
||||
, pipe varchar(32) references tj.pipes(id) not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
create table tj.reactions_tank
|
||||
(
|
||||
tank varchar(32) references tj.tanks(id) not null
|
||||
, value numeric not null
|
||||
);
|
||||
|
||||
create table tj.reactions_limiting_potential
|
||||
(
|
||||
value numeric not null
|
||||
);
|
||||
|
||||
create table tj.reactions_roughness_correlation
|
||||
(
|
||||
value numeric not null
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [JUNCTIONS]
|
||||
-- [junctions]
|
||||
|
||||
CREATE TABLE JUNCTIONS
|
||||
create table tj.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 tj.node(id)
|
||||
, elevation numeric not null
|
||||
, demand numeric
|
||||
, pattern varchar(32) references tj.pattern(id)
|
||||
);
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
-- [MIXING]
|
||||
-- [mixing]
|
||||
|
||||
CREATE TYPE MIXING_Model AS ENUM ('MIXED', '2COMP', 'FIFO', 'LIFO');
|
||||
|
||||
CREATE TABLE MIXING
|
||||
create type tj.mixing_model as enum
|
||||
(
|
||||
Tank VARCHAR(32) PRIMARY KEY REFERENCES TANKS(ID)
|
||||
, Model MIXING_Model NOT NULL
|
||||
, Value NUMERIC
|
||||
'mixed'
|
||||
, '2comp'
|
||||
, 'fifo'
|
||||
, 'lifo'
|
||||
);
|
||||
|
||||
create table tj.mixing
|
||||
(
|
||||
tank varchar(32) primary key references tj.tanks(id)
|
||||
, model tj.mixing_model not null
|
||||
, value numeric
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [TIMES]
|
||||
-- [times]
|
||||
|
||||
-- TODO: constraint
|
||||
-- todo: constraint
|
||||
|
||||
CREATE TABLE TIMES
|
||||
create table tj.times
|
||||
(
|
||||
Key TEXT NOT NULL
|
||||
, Value TEXT NOT NULL
|
||||
key text not null
|
||||
, value text not null
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [REPORT]
|
||||
-- [report]
|
||||
|
||||
-- TODO: constraint
|
||||
-- todo: constraint
|
||||
|
||||
CREATE TABLE REPORT
|
||||
create table tj.report
|
||||
(
|
||||
Key TEXT NOT NULL
|
||||
, Value TEXT NOT NULL
|
||||
key text not null
|
||||
, value text not null
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [OPTIONS]
|
||||
-- [options]
|
||||
|
||||
-- TODO: constraint
|
||||
-- todo: constraint
|
||||
|
||||
CREATE TABLE OPTIONS
|
||||
create table tj.options
|
||||
(
|
||||
Key TEXT NOT NULL
|
||||
, Value TEXT NOT NULL
|
||||
key text not null
|
||||
, value text not null
|
||||
);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
-- [COORDINATES]
|
||||
-- [coordinates]
|
||||
|
||||
CREATE TABLE COORDINATES
|
||||
create table tj.coordinates
|
||||
(
|
||||
Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, Coord POINT NOT NULL
|
||||
node varchar(32) primary key references tj.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 tj.coordinates_spgist on tj.coordinates using spgist(coord);
|
||||
create index tj.coordinates_gist on tj.coordinates using gist(coord);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- [VERTICES]
|
||||
-- [vertices]
|
||||
|
||||
CREATE TABLE VERTICES
|
||||
create table tj.vertices
|
||||
(
|
||||
Link VARCHAR(32) REFERENCES _LINK(ID) NOT NULL
|
||||
, X NUMERIC NOT NULL
|
||||
, Y NUMERIC NOT NULL
|
||||
link varchar(32) references tj.link(id) not null
|
||||
, x numeric not null
|
||||
, y numeric not null
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [LABELS]
|
||||
-- [labels]
|
||||
|
||||
CREATE TABLE LABELS
|
||||
create table tj.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 tj.node(id)
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- [BACKDROP]
|
||||
-- [backdrop]
|
||||
|
||||
CREATE TABLE BACKDROP
|
||||
create table tj.backdrop
|
||||
(
|
||||
Content TEXT PRIMARY KEY
|
||||
content text primary key
|
||||
);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- [RESERVOIRS]
|
||||
-- [reservoirs]
|
||||
|
||||
CREATE TABLE RESERVOIRS
|
||||
create table tj.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 tj.node(id)
|
||||
, head numeric not null
|
||||
, pattern varchar(32) references tj.pattern(id)
|
||||
);
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
-- [TANKS]
|
||||
-- [tanks]
|
||||
|
||||
CREATE TYPE TANKS_OVERFLOW AS ENUM ('YES', 'NO');
|
||||
|
||||
CREATE TABLE TANKS
|
||||
create type tj.tanks_overflow as enum
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, Elevation NUMERIC NOT NULL
|
||||
, InitLevel NUMERIC NOT NULL
|
||||
, MinLevel NUMERIC NOT NULL
|
||||
, MaxLevel NUMERIC NOT NULL
|
||||
, Diameter NUMERIC NOT NULL
|
||||
, MinVol NUMERIC NOT NULL
|
||||
, VolCurve VARCHAR(32) REFERENCES _CURVE(ID)
|
||||
, Overflow TANKS_OVERFLOW
|
||||
'yes'
|
||||
, 'no'
|
||||
);
|
||||
|
||||
create table tj.tanks
|
||||
(
|
||||
id varchar(32) primary key references tj.node(id)
|
||||
, elevation numeric not null
|
||||
, initlevel numeric not null
|
||||
, minlevel numeric not null
|
||||
, maxlevel numeric not null
|
||||
, diameter numeric not null
|
||||
, minvol numeric not null
|
||||
, volcurve varchar(32) references tj.curve(id)
|
||||
, overflow tj.tanks_overflow
|
||||
);
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
-- [PIPES]
|
||||
-- [pipes]
|
||||
|
||||
CREATE TYPE PIPES_STATUS AS ENUM ('OPEN', 'CLOSED', 'CV');
|
||||
|
||||
CREATE TABLE PIPES
|
||||
create type tj.pipes_status as enum
|
||||
(
|
||||
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
|
||||
, MinorLoss NUMERIC NOT NULL
|
||||
, Status PIPES_STATUS NOT NULL
|
||||
'open'
|
||||
, 'closed'
|
||||
, 'cv'
|
||||
);
|
||||
|
||||
create table tj.pipes
|
||||
(
|
||||
id varchar(32) primary key references tj.link(id)
|
||||
, node1 varchar(32) references tj.node(id) not null
|
||||
, node2 varchar(32) references tj.node(id) not null
|
||||
, length numeric not null
|
||||
, diameter numeric not null
|
||||
, roughness numeric not null
|
||||
, minorloss numeric not null
|
||||
, status tj.pipes_status not null
|
||||
);
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
-- [PUMPS]
|
||||
-- [pumps]
|
||||
|
||||
CREATE TABLE PUMPS
|
||||
create table tj.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 tj.link(id)
|
||||
, node1 varchar(32) references tj.node(id) not null
|
||||
, node2 varchar(32) references tj.node(id) not null
|
||||
);
|
||||
|
||||
CREATE TABLE PUMPS_PROPERTY_POWER
|
||||
create table tj.pumps_property_power
|
||||
(
|
||||
ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID)
|
||||
, Value VARCHAR(32) NOT NULL
|
||||
id varchar primary key references tj.pumps(id)
|
||||
, value varchar(32) not null
|
||||
);
|
||||
|
||||
CREATE TABLE PUMPS_PROPERTY_SPEED
|
||||
create table tj.pumps_property_speed
|
||||
(
|
||||
ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID)
|
||||
, Value VARCHAR(32) NOT NULL
|
||||
id varchar primary key references tj.pumps(id)
|
||||
, value varchar(32) not null
|
||||
);
|
||||
|
||||
CREATE TABLE PUMPS_PROPERTY_HEAD
|
||||
create table tj.pumps_property_head
|
||||
(
|
||||
ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID)
|
||||
, Head VARCHAR(32) REFERENCES _CURVE(ID) NOT NULL
|
||||
id varchar primary key references tj.pumps(id)
|
||||
, head varchar(32) references tj.curve(id) not null
|
||||
);
|
||||
|
||||
CREATE TABLE PUMPS_PROPERTY_PATTERN
|
||||
create table tj.pumps_property_pattern
|
||||
(
|
||||
ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID)
|
||||
, Pattern VARCHAR(32) REFERENCES _PATTERN(ID) NOT NULL
|
||||
id varchar primary key references tj.pumps(id)
|
||||
, pattern varchar(32) references tj.pattern(id) not null
|
||||
);
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
-- [VALVES]
|
||||
-- [valves]
|
||||
|
||||
CREATE TYPE VALVES_TYPE AS ENUM ('PRV', 'PSV', 'PBV', 'FCV', 'TCV', 'GPV');
|
||||
|
||||
CREATE TABLE VALVES
|
||||
create type tj.valves_type as enum
|
||||
(
|
||||
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
|
||||
, MinorLoss NUMERIC NOT NULL
|
||||
'prv'
|
||||
, 'psv'
|
||||
, 'pbv'
|
||||
, 'fcv'
|
||||
, 'tcv'
|
||||
, 'gpv'
|
||||
);
|
||||
|
||||
create table tj.valves
|
||||
(
|
||||
id varchar(32) primary key references tj.link(id)
|
||||
, node1 varchar(32) references tj.node(id) not null
|
||||
, node2 varchar(32) references tj.node(id) not null
|
||||
, diameter numeric not null
|
||||
, type tj.valves_type not null
|
||||
, setting numeric not null
|
||||
, minorloss numeric not null
|
||||
);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
-- [TAGS]
|
||||
-- [tags]
|
||||
|
||||
CREATE TABLE TAGS_NODE
|
||||
create table tj.tags_node
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID)
|
||||
, Tag TEXT NOT NULL
|
||||
id varchar(32) primary key references tj.node(id)
|
||||
, tag text not null
|
||||
);
|
||||
|
||||
CREATE TABLE TAGS_LINK
|
||||
create table tj.tags_link
|
||||
(
|
||||
ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
|
||||
, Tag TEXT NOT NULL
|
||||
id varchar(32) primary key references tj.link(id)
|
||||
, tag text not null
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [DEMANDS]
|
||||
-- [demands]
|
||||
|
||||
CREATE TABLE DEMANDS
|
||||
create table tj.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 tj.junctions(id) not null
|
||||
, demand numeric not null
|
||||
, pattern varchar(32) references tj.pattern(id)
|
||||
, category text not null
|
||||
);
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
CREATE TABLE OPERATION
|
||||
create table tj.operation
|
||||
(
|
||||
ID SERIAL PRIMARY KEY
|
||||
, Redo TEXT NOT NULL
|
||||
, Undo TEXT NOT NULL
|
||||
, Parent INTEGER REFERENCES OPERATION(ID)
|
||||
, Redo_Child INTEGER REFERENCES OPERATION(ID)
|
||||
id serial primary key
|
||||
, redo text not null
|
||||
, undo text not null
|
||||
, parent integer references tj.operation(id)
|
||||
, redo_child integer references tj.operation(id)
|
||||
);
|
||||
|
||||
INSERT INTO OPERATION (ID, Redo, Undo) VALUES (0, '', '');
|
||||
insert into tj.operation (id, redo, undo) values (0, '', '');
|
||||
|
||||
CREATE TABLE CURRENT_OPERATION
|
||||
create table tj.current_operation
|
||||
(
|
||||
ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID)
|
||||
id integer primary key references tj.operation(id)
|
||||
);
|
||||
|
||||
INSERT INTO CURRENT_OPERATION (ID) VALUES (0);
|
||||
insert into tj.current_operation (id) values (0);
|
||||
|
||||
CREATE TABLE SNAPSHOT_OPERATION
|
||||
create table tj.snapshot_operation
|
||||
(
|
||||
ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID)
|
||||
, Tag TEXT NOT NULL UNIQUE
|
||||
id integer primary key references tj.operation(id)
|
||||
, tag text not null unique
|
||||
);
|
||||
|
||||
CREATE TABLE TRANSACTION_OPERATION
|
||||
create table tj.transaction_operation
|
||||
(
|
||||
ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID)
|
||||
, STRICT BOOLEAN NOT NULL DEFAULT FALSE
|
||||
id integer primary key references tj.operation(id)
|
||||
, strict boolean not null default false
|
||||
);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
DROP TABLE IF EXISTS _PATTERN;
|
||||
drop table if exists tj.pattern;
|
||||
|
||||
DROP TABLE IF EXISTS _CURVE;
|
||||
drop table if exists tj.curve;
|
||||
|
||||
DROP TABLE IF EXISTS _LINK;
|
||||
drop table if exists tj.link;
|
||||
|
||||
DROP TABLE IF EXISTS _NODE;
|
||||
drop table if exists tj.node;
|
||||
|
||||
DROP TYPE IF EXISTS _LINK_TYPE;
|
||||
drop type if exists tj.link_type;
|
||||
|
||||
DROP TYPE IF EXISTS _NODE_TYPE;
|
||||
drop type if exists tj.node_type;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [TITLE]
|
||||
-- [title]
|
||||
|
||||
DROP TABLE IF EXISTS TITLE;
|
||||
drop table if exists tj.title;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
-- [STATUS]
|
||||
-- [status]
|
||||
|
||||
DROP TABLE IF EXISTS STATUS_LINK;
|
||||
drop table if exists tj.status_link;
|
||||
|
||||
DROP TABLE IF EXISTS STATUS_VALVE;
|
||||
drop table if exists tj.status_valve;
|
||||
|
||||
DROP TYPE IF EXISTS STATUS_VALVE_STATUS;
|
||||
drop type if exists tj.status_valve_status;
|
||||
|
||||
DROP TABLE IF EXISTS STATUS_PUMP;
|
||||
drop table if exists tj.status_pump;
|
||||
|
||||
DROP TABLE IF EXISTS STATUS_PIPE;
|
||||
drop table if exists tj.status_pipe;
|
||||
|
||||
DROP TYPE IF EXISTS STATUS_PIPE_PUMP_STATUS;
|
||||
drop type if exists tj.status_pipe_pump_status;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [PATTERNS]
|
||||
-- [patterns]
|
||||
|
||||
DROP TABLE IF EXISTS PATTERNS;
|
||||
drop table if exists tj.patterns;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [CURVES]
|
||||
-- [curves]
|
||||
|
||||
DROP TABLE IF EXISTS CURVES;
|
||||
drop table if exists tj.curves;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [CONTROLS]
|
||||
-- [controls]
|
||||
|
||||
DROP TABLE IF EXISTS CONTROLS_3;
|
||||
drop table if exists tj.controls_3;
|
||||
|
||||
DROP TABLE IF EXISTS CONTROLS_2;
|
||||
drop table if exists tj.controls_2;
|
||||
|
||||
DROP TABLE IF EXISTS CONTROLS_1;
|
||||
drop table if exists tj.controls_1;
|
||||
|
||||
DROP TYPE IF EXISTS CONTROLS_1_PREP;
|
||||
drop type if exists tj.controls_1_prep;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [RULES]
|
||||
-- [rules]
|
||||
|
||||
DROP TABLE IF EXISTS RULES;
|
||||
drop table if exists tj.rules;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- [ENERGY]
|
||||
-- [energy]
|
||||
|
||||
DROP TABLE IF EXISTS ENERGY_DEMAND_CHARGE;
|
||||
drop table if exists tj.energy_demand_charge;
|
||||
|
||||
DROP TABLE IF EXISTS ENERGY_PUMP;
|
||||
drop table if exists tj.energy_pump;
|
||||
|
||||
DROP TABLE IF EXISTS ENERGY_GLOBAL;
|
||||
drop table if exists tj.energy_global;
|
||||
|
||||
DROP TYPE IF EXISTS ENERGY_PARAM;
|
||||
drop type if exists tj.energy_param;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [EMITTERS]
|
||||
-- [emitters]
|
||||
|
||||
DROP TABLE IF EXISTS EMITTERS;
|
||||
drop table if exists tj.emitters;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [QUALITY]
|
||||
-- [quality]
|
||||
|
||||
DROP TABLE IF EXISTS QUALITY;
|
||||
drop table if exists tj.quality;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [SOURCES]
|
||||
-- [sources]
|
||||
|
||||
DROP TABLE IF EXISTS SOURCES;
|
||||
drop table if exists tj.sources;
|
||||
|
||||
DROP TYPE IF EXISTS SOURCES_TYPE;
|
||||
drop type if exists tj.sources_type;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
-- [REACTIONS]
|
||||
-- [reactions]
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_ROUGHNESS_CORRELATION;
|
||||
drop table if exists tj.reactions_roughness_correlation;
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_LIMITING_POTENTIAL;
|
||||
drop table if exists tj.reactions_limiting_potential;
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_TANK;
|
||||
drop table if exists tj.reactions_tank;
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_PIPE;
|
||||
drop table if exists tj.reactions_pipe;
|
||||
|
||||
DROP TYPE IF EXISTS REACTIONS_PIPE_PARAM;
|
||||
drop type if exists tj.reactions_pipe_param;
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_GLOBAL;
|
||||
drop table if exists tj.reactions_global;
|
||||
|
||||
DROP TYPE IF EXISTS REACTIONS_GLOBAL_PARAM;
|
||||
drop type if exists tj.reactions_global_param;
|
||||
|
||||
DROP TABLE IF EXISTS REACTIONS_ORDER;
|
||||
drop table if exists tj.reactions_order;
|
||||
|
||||
DROP TYPE IF EXISTS REACTIONS_ORDER_PARAM;
|
||||
drop type if exists tj.reactions_order_param;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [JUNCTIONS]
|
||||
-- [junctions]
|
||||
|
||||
DROP TABLE IF EXISTS JUNCTIONS;
|
||||
drop table if exists tj.junctions;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [MIXING]
|
||||
-- [mixing]
|
||||
|
||||
DROP TABLE IF EXISTS MIXING;
|
||||
drop table if exists tj.mixing;
|
||||
|
||||
DROP TYPE IF EXISTS MIXING_Model;
|
||||
drop type if exists tj.mixing_model;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [TIMES]
|
||||
-- [times]
|
||||
|
||||
DROP TABLE IF EXISTS TIMES;
|
||||
drop table if exists tj.times;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [REPORT]
|
||||
-- [report]
|
||||
|
||||
DROP TABLE IF EXISTS REPORT;
|
||||
drop table if exists tj.report;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [OPTIONS]
|
||||
-- [options]
|
||||
|
||||
DROP TABLE IF EXISTS OPTIONS;
|
||||
drop table if exists tj.options;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- [COORDINATES]
|
||||
-- [coordinates]
|
||||
|
||||
DROP INDEX IF EXISTS COORDINATES_GIST;
|
||||
drop index if exists tj.coordinates_gist;
|
||||
|
||||
DROP INDEX IF EXISTS COORDINATES_SPGIST;
|
||||
drop index if exists tj.coordinates_spgist;
|
||||
|
||||
DROP TABLE IF EXISTS COORDINATES;
|
||||
drop table if exists tj.coordinates;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [VERTICES]
|
||||
-- [vertices]
|
||||
|
||||
DROP TABLE IF EXISTS VERTICES;
|
||||
drop table if exists tj.vertices;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [LABELS]
|
||||
-- [labels]
|
||||
|
||||
DROP TABLE IF EXISTS LABELS;
|
||||
drop table if exists tj.labels;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [BACKDROP]
|
||||
-- [backdrop]
|
||||
|
||||
DROP TABLE IF EXISTS BACKDROP;
|
||||
drop table if exists tj.backdrop;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [RESERVOIRS]
|
||||
-- [reservoirs]
|
||||
|
||||
DROP TABLE IF EXISTS RESERVOIRS;
|
||||
drop table if exists tj.reservoirs;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [TANKS]
|
||||
-- [tanks]
|
||||
|
||||
DROP TABLE IF EXISTS TANKS;
|
||||
drop table if exists tj.tanks;
|
||||
|
||||
DROP TYPE IF EXISTS TANKS_OVERFLOW;
|
||||
drop type if exists tj.tanks_overflow;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [PIPES]
|
||||
-- [pipes]
|
||||
|
||||
DROP TABLE IF EXISTS PIPES;
|
||||
drop table if exists tj.pipes;
|
||||
|
||||
DROP TYPE IF EXISTS PIPES_STATUS;
|
||||
drop type if exists tj.pipes_status;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
-- [PUMPS]
|
||||
-- [pumps]
|
||||
|
||||
DROP TABLE IF EXISTS PUMPS_PROPERTY_PATTERN;
|
||||
drop table if exists tj.pumps_property_pattern;
|
||||
|
||||
DROP TABLE IF EXISTS PUMPS_PROPERTY_HEAD;
|
||||
drop table if exists tj.pumps_property_head;
|
||||
|
||||
DROP TABLE IF EXISTS PUMPS_PROPERTY_SPEED;
|
||||
drop table if exists tj.pumps_property_speed;
|
||||
|
||||
DROP TABLE IF EXISTS PUMPS_PROPERTY_POWER;
|
||||
drop table if exists tj.pumps_property_power;
|
||||
|
||||
DROP TABLE IF EXISTS PUMPS;
|
||||
drop table if exists tj.pumps;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [VALVES]
|
||||
-- [valves]
|
||||
|
||||
DROP TABLE IF EXISTS VALVES;
|
||||
drop table if exists tj.valves;
|
||||
|
||||
DROP TYPE IF EXISTS VALVES_TYPE;
|
||||
drop type if exists tj.valves_type;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- [TAGS]
|
||||
-- [tags]
|
||||
|
||||
DROP TABLE IF EXISTS TAGS_LINK;
|
||||
drop table if exists tj.tags_link;
|
||||
|
||||
DROP TABLE IF EXISTS TAGS_NODE;
|
||||
drop table if exists tj.tags_node;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- [DEMANDS]
|
||||
-- [demands]
|
||||
|
||||
DROP TABLE IF EXISTS DEMANDS;
|
||||
drop table if exists tj.demands;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
DROP TABLE IF EXISTS TRANSACTION_OPERATION;
|
||||
drop table if exists tj.transaction_operation;
|
||||
|
||||
DROP TABLE IF EXISTS SNAPSHOT_OPERATION;
|
||||
drop table if exists tj.snapshot_operation;
|
||||
|
||||
DROP TABLE IF EXISTS CURRENT_OPERATION;
|
||||
drop table if exists tj.current_operation;
|
||||
|
||||
DROP TABLE IF EXISTS OPERATION;
|
||||
drop table if exists tj.operation;
|
||||
|
||||
Reference in New Issue
Block a user