From b77349cfe64f51023720acdaadd689b3ffc75ead Mon Sep 17 00:00:00 2001 From: wqy Date: Sat, 27 Aug 2022 11:49:43 +0800 Subject: [PATCH] Add epanet input schema --- sql/base_create.sql | 25 ++++++++++++++++ sql/base_drop.sql | 11 +++++++ sql/section_create/1.title.sql | 6 ++++ sql/section_create/10.status.sql | 29 ++++++++++++++++++ sql/section_create/11.patterns.sql | 7 +++++ sql/section_create/12.curves.sql | 8 +++++ sql/section_create/13.controls.sql | 30 +++++++++++++++++++ sql/section_create/14.rules.sql | 6 ++++ sql/section_create/15.energy.sql | 24 +++++++++++++++ sql/section_create/16.emitters.sql | 7 +++++ sql/section_create/17.quality.sql | 7 +++++ sql/section_create/18.sources.sql | 11 +++++++ sql/section_create/19.reactions.sql | 42 +++++++++++++++++++++++++++ sql/section_create/2.junctions.sql | 9 ++++++ sql/section_create/20.mixing.sql | 10 +++++++ sql/section_create/21.times.sql | 9 ++++++ sql/section_create/22.report.sql | 9 ++++++ sql/section_create/23.options.sql | 9 ++++++ sql/section_create/24.coordinates.sql | 10 +++++++ sql/section_create/25.vertices.sql | 8 +++++ sql/section_create/26.labels.sql | 9 ++++++ sql/section_create/27.backdrop.sql | 6 ++++ sql/section_create/28.end.sql | 1 + sql/section_create/3.reservoirs.sql | 8 +++++ sql/section_create/4.tanks.sql | 16 ++++++++++ sql/section_create/5.pipes.sql | 15 ++++++++++ sql/section_create/6.pumps.sql | 32 ++++++++++++++++++++ sql/section_create/7.valves.sql | 14 +++++++++ sql/section_create/8.tags.sql | 13 +++++++++ sql/section_create/9.demands.sql | 9 ++++++ sql/section_drop/1.title.sql | 3 ++ sql/section_drop/10.status.sql | 13 +++++++++ sql/section_drop/11.patterns.sql | 3 ++ sql/section_drop/12.curves.sql | 3 ++ sql/section_drop/13.controls.sql | 9 ++++++ sql/section_drop/14.rules.sql | 3 ++ sql/section_drop/15.energy.sql | 9 ++++++ sql/section_drop/16.emitters.sql | 3 ++ sql/section_drop/17.quality.sql | 3 ++ sql/section_drop/18.sources.sql | 5 ++++ sql/section_drop/19.reactions.sql | 19 ++++++++++++ sql/section_drop/2.junctions.sql | 3 ++ sql/section_drop/20.mixing.sql | 5 ++++ sql/section_drop/21.times.sql | 3 ++ sql/section_drop/22.report.sql | 3 ++ sql/section_drop/23.options.sql | 3 ++ sql/section_drop/24.coordinates.sql | 7 +++++ sql/section_drop/25.vertices.sql | 3 ++ sql/section_drop/26.labels.sql | 3 ++ sql/section_drop/27.backdrop.sql | 3 ++ sql/section_drop/28.end.sql | 1 + sql/section_drop/3.reservoirs.sql | 3 ++ sql/section_drop/4.tanks.sql | 5 ++++ sql/section_drop/5.pipes.sql | 5 ++++ sql/section_drop/6.pumps.sql | 11 +++++++ sql/section_drop/7.valves.sql | 5 ++++ sql/section_drop/8.tags.sql | 5 ++++ sql/section_drop/9.demands.sql | 3 ++ 58 files changed, 544 insertions(+) create mode 100644 sql/base_create.sql create mode 100644 sql/base_drop.sql create mode 100644 sql/section_create/1.title.sql create mode 100644 sql/section_create/10.status.sql create mode 100644 sql/section_create/11.patterns.sql create mode 100644 sql/section_create/12.curves.sql create mode 100644 sql/section_create/13.controls.sql create mode 100644 sql/section_create/14.rules.sql create mode 100644 sql/section_create/15.energy.sql create mode 100644 sql/section_create/16.emitters.sql create mode 100644 sql/section_create/17.quality.sql create mode 100644 sql/section_create/18.sources.sql create mode 100644 sql/section_create/19.reactions.sql create mode 100644 sql/section_create/2.junctions.sql create mode 100644 sql/section_create/20.mixing.sql create mode 100644 sql/section_create/21.times.sql create mode 100644 sql/section_create/22.report.sql create mode 100644 sql/section_create/23.options.sql create mode 100644 sql/section_create/24.coordinates.sql create mode 100644 sql/section_create/25.vertices.sql create mode 100644 sql/section_create/26.labels.sql create mode 100644 sql/section_create/27.backdrop.sql create mode 100644 sql/section_create/28.end.sql create mode 100644 sql/section_create/3.reservoirs.sql create mode 100644 sql/section_create/4.tanks.sql create mode 100644 sql/section_create/5.pipes.sql create mode 100644 sql/section_create/6.pumps.sql create mode 100644 sql/section_create/7.valves.sql create mode 100644 sql/section_create/8.tags.sql create mode 100644 sql/section_create/9.demands.sql create mode 100644 sql/section_drop/1.title.sql create mode 100644 sql/section_drop/10.status.sql create mode 100644 sql/section_drop/11.patterns.sql create mode 100644 sql/section_drop/12.curves.sql create mode 100644 sql/section_drop/13.controls.sql create mode 100644 sql/section_drop/14.rules.sql create mode 100644 sql/section_drop/15.energy.sql create mode 100644 sql/section_drop/16.emitters.sql create mode 100644 sql/section_drop/17.quality.sql create mode 100644 sql/section_drop/18.sources.sql create mode 100644 sql/section_drop/19.reactions.sql create mode 100644 sql/section_drop/2.junctions.sql create mode 100644 sql/section_drop/20.mixing.sql create mode 100644 sql/section_drop/21.times.sql create mode 100644 sql/section_drop/22.report.sql create mode 100644 sql/section_drop/23.options.sql create mode 100644 sql/section_drop/24.coordinates.sql create mode 100644 sql/section_drop/25.vertices.sql create mode 100644 sql/section_drop/26.labels.sql create mode 100644 sql/section_drop/27.backdrop.sql create mode 100644 sql/section_drop/28.end.sql create mode 100644 sql/section_drop/3.reservoirs.sql create mode 100644 sql/section_drop/4.tanks.sql create mode 100644 sql/section_drop/5.pipes.sql create mode 100644 sql/section_drop/6.pumps.sql create mode 100644 sql/section_drop/7.valves.sql create mode 100644 sql/section_drop/8.tags.sql create mode 100644 sql/section_drop/9.demands.sql diff --git a/sql/base_create.sql b/sql/base_create.sql new file mode 100644 index 0000000..4ee4fde --- /dev/null +++ b/sql/base_create.sql @@ -0,0 +1,25 @@ +CREATE TYPE _NODE_TYPE AS ENUM ('JUNCTION', 'RESERVOIR', 'TANK'); + +CREATE TYPE _LINK_TYPE AS ENUM ('PIPE', 'PUMP', 'VALVE'); + +CREATE TABLE _NODE +( + ID VARCHAR(32) PRIMARY KEY +, Type _NODE_TYPE NOT NULL +); + +CREATE TABLE _LINK +( + ID VARCHAR(32) PRIMARY KEY +, Type _LINK_TYPE NOT NULL +); + +CREATE TABLE _CURVE +( + ID VARCHAR(32) PRIMARY KEY +); + +CREATE TABLE _PATTERN +( + ID VARCHAR(32) PRIMARY KEY +); diff --git a/sql/base_drop.sql b/sql/base_drop.sql new file mode 100644 index 0000000..3b57bb0 --- /dev/null +++ b/sql/base_drop.sql @@ -0,0 +1,11 @@ +DROP TABLE IF EXISTS _PATTERN; + +DROP TABLE IF EXISTS _CURVE; + +DROP TABLE IF EXISTS _LINK; + +DROP TABLE IF EXISTS _NODE; + +DROP TYPE IF EXISTS _LINK_TYPE; + +DROP TYPE IF EXISTS _NODE_TYPE; diff --git a/sql/section_create/1.title.sql b/sql/section_create/1.title.sql new file mode 100644 index 0000000..0a48eff --- /dev/null +++ b/sql/section_create/1.title.sql @@ -0,0 +1,6 @@ +-- [TITLE] + +CREATE TABLE TITLE +( + Value TEXT +); diff --git a/sql/section_create/10.status.sql b/sql/section_create/10.status.sql new file mode 100644 index 0000000..34da1f7 --- /dev/null +++ b/sql/section_create/10.status.sql @@ -0,0 +1,29 @@ +-- [STATUS] + +CREATE TYPE STATUS_PIPE_PUMP_STATUS AS ENUM ('OPEN', 'CLOSED'); + +CREATE TABLE STATUS_PIPE +( + ID VARCHAR(32) PRIMARY KEY REFERENCES PIPES(ID) +, Status STATUS_PIPE_PUMP_STATUS NOT NULL +); + +CREATE TABLE STATUS_PUMP +( + 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 TABLE STATUS_VALVE +( + ID VARCHAR(32) PRIMARY KEY REFERENCES VALVES(ID) +, Status STATUS_VALVE_STATUS NOT NULL +); + +CREATE TABLE STATUS_LINK +( + ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID) +, Setting NUMERIC NOT NULL +); diff --git a/sql/section_create/11.patterns.sql b/sql/section_create/11.patterns.sql new file mode 100644 index 0000000..dfb23b0 --- /dev/null +++ b/sql/section_create/11.patterns.sql @@ -0,0 +1,7 @@ +-- [PATTERNS] + +CREATE TABLE PATTERNS +( + ID VARCHAR(32) REFERENCES _PATTERN(ID) NOT NULL +, Multipliers NUMERIC NOT NULL +); diff --git a/sql/section_create/12.curves.sql b/sql/section_create/12.curves.sql new file mode 100644 index 0000000..ac2460e --- /dev/null +++ b/sql/section_create/12.curves.sql @@ -0,0 +1,8 @@ +-- [CURVES] + +CREATE TABLE CURVES +( + ID VARCHAR(32) REFERENCES _CURVE(ID) NOT NULL +, X NUMERIC NOT NULL +, Y NUMERIC NOT NULL +); diff --git a/sql/section_create/13.controls.sql b/sql/section_create/13.controls.sql new file mode 100644 index 0000000..aa107eb --- /dev/null +++ b/sql/section_create/13.controls.sql @@ -0,0 +1,30 @@ +-- [CONTROLS] + +CREATE TYPE CONTROLS_1_PREP AS ENUM ('ABOVE', 'BELOW'); + +-- LINK linkID status IF NODE nodeID ABOVE / BELOW value +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 +); + +-- LINK linkID status AT TIME time +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 +); + +-- LINK linkID status AT CLOCKTIME clocktime AM / PM +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 +, ClockTimeHour INTERVAL HOUR -- get AM/PM from it +, ClockTimeMin INTERVAL MINUTE +); diff --git a/sql/section_create/14.rules.sql b/sql/section_create/14.rules.sql new file mode 100644 index 0000000..7d288ca --- /dev/null +++ b/sql/section_create/14.rules.sql @@ -0,0 +1,6 @@ +-- [RULES] + +CREATE TABLE RULES +( + Content TEXT PRIMARY KEY +); diff --git a/sql/section_create/15.energy.sql b/sql/section_create/15.energy.sql new file mode 100644 index 0000000..a73a3db --- /dev/null +++ b/sql/section_create/15.energy.sql @@ -0,0 +1,24 @@ +-- [ENERGY] + +CREATE TYPE ENERGY_PARAM AS ENUM ('PRICE', 'PATTERN', 'EFFIC'); + +-- GLOBAL PRICE / PATTERN / EFFIC value +CREATE TABLE ENERGY_GLOBAL +( + Param ENERGY_PARAM NOT NULL +, Value NUMERIC NOT NULL +); + +-- PUMP pumpID PRICE / PATTERN / EFFIC value +CREATE TABLE ENERGY_PUMP +( + 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 +( + Value NUMERIC NOT NULL +); diff --git a/sql/section_create/16.emitters.sql b/sql/section_create/16.emitters.sql new file mode 100644 index 0000000..b1fe8b4 --- /dev/null +++ b/sql/section_create/16.emitters.sql @@ -0,0 +1,7 @@ +-- [EMITTERS] + +CREATE TABLE EMITTERS +( + Junction VARCHAR(32) PRIMARY KEY REFERENCES JUNCTIONS(ID) +, Coefficient NUMERIC NOT NULL +); diff --git a/sql/section_create/17.quality.sql b/sql/section_create/17.quality.sql new file mode 100644 index 0000000..939e309 --- /dev/null +++ b/sql/section_create/17.quality.sql @@ -0,0 +1,7 @@ +-- [QUALITY] + +CREATE TABLE QUALITY +( + Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) +, InitialQual NUMERIC NOT NULL +); diff --git a/sql/section_create/18.sources.sql b/sql/section_create/18.sources.sql new file mode 100644 index 0000000..1c2ec64 --- /dev/null +++ b/sql/section_create/18.sources.sql @@ -0,0 +1,11 @@ +-- [SOURCES] + +CREATE TYPE SOURCES_TYPE AS ENUM ('CONCEN', 'MASS', 'FLOWPACED', 'SETPOINT'); + +CREATE TABLE SOURCES +( + Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) +, Type SOURCES_TYPE NOT NULL +, Strength NUMERIC NOT NULL +, TimePattern VARCHAR(32) REFERENCES _PATTERN(ID) +); diff --git a/sql/section_create/19.reactions.sql b/sql/section_create/19.reactions.sql new file mode 100644 index 0000000..0d8d13b --- /dev/null +++ b/sql/section_create/19.reactions.sql @@ -0,0 +1,42 @@ +-- [REACTIONS] + +CREATE TYPE REACTIONS_ORDER_PARAM AS ENUM ('BULK', 'WALL', 'TANK'); + +CREATE TABLE REACTIONS_ORDER +( + Key REACTIONS_ORDER_PARAM NOT NULL +, Value NUMERIC NOT NULL +); + +CREATE TYPE REACTIONS_GLOBAL_PARAM AS ENUM ('BULK', 'WALL'); + +CREATE TABLE REACTIONS_GLOBAL +( + Key REACTIONS_GLOBAL_PARAM NOT NULL +, Value NUMERIC NOT NULL +); + +CREATE TYPE REACTIONS_PIPE_PARAM AS ENUM ('BULK', 'WALL'); + +CREATE TABLE REACTIONS_PIPE +( + Key REACTIONS_PIPE_PARAM NOT NULL +, Pipe VARCHAR(32) REFERENCES PIPES(ID) NOT NULL +, Value NUMERIC NOT NULL +); + +CREATE TABLE REACTIONS_TANK +( + Tank VARCHAR(32) REFERENCES TANKS(ID) NOT NULL +, Value NUMERIC NOT NULL +); + +CREATE TABLE REACTIONS_LIMITING_POTENTIAL +( + Value NUMERIC NOT NULL +); + +CREATE TABLE REACTIONS_ROUGHNESS_CORRELATION +( + Value NUMERIC NOT NULL +); diff --git a/sql/section_create/2.junctions.sql b/sql/section_create/2.junctions.sql new file mode 100644 index 0000000..42ea2f3 --- /dev/null +++ b/sql/section_create/2.junctions.sql @@ -0,0 +1,9 @@ +-- [JUNCTIONS] + +CREATE TABLE JUNCTIONS +( + ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) +, Elevation NUMERIC NOT NULL +, Demand NUMERIC +, Pattern VARCHAR(32) REFERENCES _PATTERN(ID) +); diff --git a/sql/section_create/20.mixing.sql b/sql/section_create/20.mixing.sql new file mode 100644 index 0000000..b6675bb --- /dev/null +++ b/sql/section_create/20.mixing.sql @@ -0,0 +1,10 @@ +-- [MIXING] + +CREATE TYPE MIXING_Model AS ENUM ('MIXED', '2COMP', 'FIFO', 'LIFO'); + +CREATE TABLE MIXING +( + Tank VARCHAR(32) PRIMARY KEY REFERENCES TANKS(ID) +, Model MIXING_Model NOT NULL +, Value NUMERIC +); diff --git a/sql/section_create/21.times.sql b/sql/section_create/21.times.sql new file mode 100644 index 0000000..a68e504 --- /dev/null +++ b/sql/section_create/21.times.sql @@ -0,0 +1,9 @@ +-- [TIMES] + +-- TODO: constraint + +CREATE TABLE TIMES +( + Key TEXT NOT NULL +, Value TEXT NOT NULL +); diff --git a/sql/section_create/22.report.sql b/sql/section_create/22.report.sql new file mode 100644 index 0000000..c2435d3 --- /dev/null +++ b/sql/section_create/22.report.sql @@ -0,0 +1,9 @@ +-- [REPORT] + +-- TODO: constraint + +CREATE TABLE REPORT +( + Key TEXT NOT NULL +, Value TEXT NOT NULL +); diff --git a/sql/section_create/23.options.sql b/sql/section_create/23.options.sql new file mode 100644 index 0000000..16d50a4 --- /dev/null +++ b/sql/section_create/23.options.sql @@ -0,0 +1,9 @@ +-- [OPTIONS] + +-- TODO: constraint + +CREATE TABLE OPTIONS +( + Key TEXT NOT NULL +, Value TEXT NOT NULL +); diff --git a/sql/section_create/24.coordinates.sql b/sql/section_create/24.coordinates.sql new file mode 100644 index 0000000..2bad5dc --- /dev/null +++ b/sql/section_create/24.coordinates.sql @@ -0,0 +1,10 @@ +-- [COORDINATES] + +CREATE TABLE COORDINATES +( + Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) +, Coord POINT NOT NULL DEFAULT(POINT(0.0, 0.0)) +); + +CREATE INDEX COORDINATES_SPGIST ON COORDINATES USING SPGIST(Coord); +CREATE INDEX COORDINATES_GIST ON COORDINATES USING GIST(Coord); diff --git a/sql/section_create/25.vertices.sql b/sql/section_create/25.vertices.sql new file mode 100644 index 0000000..3f509c6 --- /dev/null +++ b/sql/section_create/25.vertices.sql @@ -0,0 +1,8 @@ +-- [VERTICES] + +CREATE TABLE VERTICES +( + Link VARCHAR(32) REFERENCES _LINK(ID) NOT NULL +, X NUMERIC NOT NULL +, Y NUMERIC NOT NULL +); diff --git a/sql/section_create/26.labels.sql b/sql/section_create/26.labels.sql new file mode 100644 index 0000000..cf95e00 --- /dev/null +++ b/sql/section_create/26.labels.sql @@ -0,0 +1,9 @@ +-- [LABELS] + +CREATE TABLE LABELS +( + X NUMERIC NOT NULL +, Y NUMERIC NOT NULL +, Label TEXT NOT NULL +, AnchorNode VARCHAR(32) REFERENCES _NODE(ID) +); diff --git a/sql/section_create/27.backdrop.sql b/sql/section_create/27.backdrop.sql new file mode 100644 index 0000000..4216368 --- /dev/null +++ b/sql/section_create/27.backdrop.sql @@ -0,0 +1,6 @@ +-- [BACKDROP] + +CREATE TABLE BACKDROP +( + Content TEXT PRIMARY KEY +); diff --git a/sql/section_create/28.end.sql b/sql/section_create/28.end.sql new file mode 100644 index 0000000..3054ad0 --- /dev/null +++ b/sql/section_create/28.end.sql @@ -0,0 +1 @@ +-- [END] \ No newline at end of file diff --git a/sql/section_create/3.reservoirs.sql b/sql/section_create/3.reservoirs.sql new file mode 100644 index 0000000..476c793 --- /dev/null +++ b/sql/section_create/3.reservoirs.sql @@ -0,0 +1,8 @@ +-- [RESERVOIRS] + +CREATE TABLE RESERVOIRS +( + ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) +, Head NUMERIC NOT NULL +, Pattern VARCHAR(32) REFERENCES _PATTERN(ID) +); diff --git a/sql/section_create/4.tanks.sql b/sql/section_create/4.tanks.sql new file mode 100644 index 0000000..df0bdf4 --- /dev/null +++ b/sql/section_create/4.tanks.sql @@ -0,0 +1,16 @@ +-- [TANKS] + +CREATE TYPE TANKS_OVERFLOW AS ENUM ('YES', 'NO'); + +CREATE TABLE TANKS +( + 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 +); diff --git a/sql/section_create/5.pipes.sql b/sql/section_create/5.pipes.sql new file mode 100644 index 0000000..fb1dc2d --- /dev/null +++ b/sql/section_create/5.pipes.sql @@ -0,0 +1,15 @@ +-- [PIPES] + +CREATE TYPE PIPES_STATUS AS ENUM ('OPEN', 'CLOSED', 'CV'); + +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 +, MinorLoss NUMERIC NOT NULL +, Status PIPES_STATUS NOT NULL +); diff --git a/sql/section_create/6.pumps.sql b/sql/section_create/6.pumps.sql new file mode 100644 index 0000000..b701708 --- /dev/null +++ b/sql/section_create/6.pumps.sql @@ -0,0 +1,32 @@ +-- [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 +); + +CREATE TABLE PUMPS_PROPERTY_POWER +( + ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID) +, Value VARCHAR(32) NOT NULL +); + +CREATE TABLE PUMPS_PROPERTY_SPEED +( + ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID) +, Value VARCHAR(32) NOT NULL +); + +CREATE TABLE PUMPS_PROPERTY_HEAD +( + ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID) +, Head VARCHAR(32) REFERENCES _CURVE(ID) NOT NULL +); + +CREATE TABLE PUMPS_PROPERTY_PATTERN +( + ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID) +, Pattern VARCHAR(32) REFERENCES _PATTERN(ID) NOT NULL +); diff --git a/sql/section_create/7.valves.sql b/sql/section_create/7.valves.sql new file mode 100644 index 0000000..7159aac --- /dev/null +++ b/sql/section_create/7.valves.sql @@ -0,0 +1,14 @@ +-- [VALVES] + +CREATE TYPE VALVES_TYPE AS ENUM ('PRV', 'PSV', 'PBV', 'FCV', 'TCV', 'GPV'); + +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 +, MinorLoss NUMERIC NOT NULL +); diff --git a/sql/section_create/8.tags.sql b/sql/section_create/8.tags.sql new file mode 100644 index 0000000..0cc496c --- /dev/null +++ b/sql/section_create/8.tags.sql @@ -0,0 +1,13 @@ +-- [TAGS] + +CREATE TABLE TAGS_NODE +( + ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) +, Tag TEXT NOT NULL +); + +CREATE TABLE TAGS_LINK +( + ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID) +, Tag TEXT NOT NULL +); diff --git a/sql/section_create/9.demands.sql b/sql/section_create/9.demands.sql new file mode 100644 index 0000000..355354d --- /dev/null +++ b/sql/section_create/9.demands.sql @@ -0,0 +1,9 @@ +-- [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 +); diff --git a/sql/section_drop/1.title.sql b/sql/section_drop/1.title.sql new file mode 100644 index 0000000..215ecc6 --- /dev/null +++ b/sql/section_drop/1.title.sql @@ -0,0 +1,3 @@ +-- [TITLE] + +DROP TABLE TITLE; diff --git a/sql/section_drop/10.status.sql b/sql/section_drop/10.status.sql new file mode 100644 index 0000000..970330e --- /dev/null +++ b/sql/section_drop/10.status.sql @@ -0,0 +1,13 @@ +-- [STATUS] + +DROP TABLE STATUS_LINK; + +DROP TABLE STATUS_VALVE; + +DROP TYPE STATUS_VALVE_STATUS; + +DROP TABLE STATUS_PUMP; + +DROP TABLE STATUS_PIPE; + +DROP TYPE STATUS_PIPE_PUMP_STATUS; diff --git a/sql/section_drop/11.patterns.sql b/sql/section_drop/11.patterns.sql new file mode 100644 index 0000000..565c67e --- /dev/null +++ b/sql/section_drop/11.patterns.sql @@ -0,0 +1,3 @@ +-- [PATTERNS] + +DROP TABLE PATTERNS; diff --git a/sql/section_drop/12.curves.sql b/sql/section_drop/12.curves.sql new file mode 100644 index 0000000..9535588 --- /dev/null +++ b/sql/section_drop/12.curves.sql @@ -0,0 +1,3 @@ +-- [CURVES] + +DROP TABLE CURVES; diff --git a/sql/section_drop/13.controls.sql b/sql/section_drop/13.controls.sql new file mode 100644 index 0000000..5333175 --- /dev/null +++ b/sql/section_drop/13.controls.sql @@ -0,0 +1,9 @@ +-- [CONTROLS] + +DROP TABLE CONTROLS_3; + +DROP TABLE CONTROLS_2; + +DROP TABLE CONTROLS_1; + +DROP TYPE CONTROLS_1_PREP; diff --git a/sql/section_drop/14.rules.sql b/sql/section_drop/14.rules.sql new file mode 100644 index 0000000..7cc4bac --- /dev/null +++ b/sql/section_drop/14.rules.sql @@ -0,0 +1,3 @@ +-- [RULES] + +DROP TABLE RULES; diff --git a/sql/section_drop/15.energy.sql b/sql/section_drop/15.energy.sql new file mode 100644 index 0000000..1da9af8 --- /dev/null +++ b/sql/section_drop/15.energy.sql @@ -0,0 +1,9 @@ +-- [ENERGY] + +DROP TABLE ENERGY_DEMAND_CHARGE; + +DROP TABLE ENERGY_PUMP; + +DROP TABLE ENERGY_GLOBAL; + +DROP TYPE ENERGY_PARAM; diff --git a/sql/section_drop/16.emitters.sql b/sql/section_drop/16.emitters.sql new file mode 100644 index 0000000..7aa46f8 --- /dev/null +++ b/sql/section_drop/16.emitters.sql @@ -0,0 +1,3 @@ +-- [EMITTERS] + +DROP TABLE EMITTERS; diff --git a/sql/section_drop/17.quality.sql b/sql/section_drop/17.quality.sql new file mode 100644 index 0000000..c15ac7d --- /dev/null +++ b/sql/section_drop/17.quality.sql @@ -0,0 +1,3 @@ +-- [QUALITY] + +DROP TABLE QUALITY; diff --git a/sql/section_drop/18.sources.sql b/sql/section_drop/18.sources.sql new file mode 100644 index 0000000..e11b7ea --- /dev/null +++ b/sql/section_drop/18.sources.sql @@ -0,0 +1,5 @@ +-- [SOURCES] + +DROP TABLE SOURCES; + +DROP TYPE SOURCES_TYPE; diff --git a/sql/section_drop/19.reactions.sql b/sql/section_drop/19.reactions.sql new file mode 100644 index 0000000..bcc9dc5 --- /dev/null +++ b/sql/section_drop/19.reactions.sql @@ -0,0 +1,19 @@ +-- [REACTIONS] + +DROP TABLE REACTIONS_ROUGHNESS_CORRELATION; + +DROP TABLE REACTIONS_LIMITING_POTENTIAL; + +DROP TABLE REACTIONS_TANK; + +DROP TABLE REACTIONS_PIPE; + +DROP TYPE REACTIONS_PIPE_PARAM; + +DROP TABLE REACTIONS_GLOBAL; + +DROP TYPE REACTIONS_GLOBAL_PARAM; + +DROP TABLE REACTIONS_ORDER; + +DROP TYPE REACTIONS_ORDER_PARAM; diff --git a/sql/section_drop/2.junctions.sql b/sql/section_drop/2.junctions.sql new file mode 100644 index 0000000..8fc23c4 --- /dev/null +++ b/sql/section_drop/2.junctions.sql @@ -0,0 +1,3 @@ +-- [JUNCTIONS] + +DROP TABLE JUNCTIONS; diff --git a/sql/section_drop/20.mixing.sql b/sql/section_drop/20.mixing.sql new file mode 100644 index 0000000..1434859 --- /dev/null +++ b/sql/section_drop/20.mixing.sql @@ -0,0 +1,5 @@ +-- [MIXING] + +DROP TABLE MIXING; + +DROP TYPE MIXING_Model; diff --git a/sql/section_drop/21.times.sql b/sql/section_drop/21.times.sql new file mode 100644 index 0000000..0d45aed --- /dev/null +++ b/sql/section_drop/21.times.sql @@ -0,0 +1,3 @@ +-- [TIMES] + +DROP TABLE TIMES; diff --git a/sql/section_drop/22.report.sql b/sql/section_drop/22.report.sql new file mode 100644 index 0000000..58dcd51 --- /dev/null +++ b/sql/section_drop/22.report.sql @@ -0,0 +1,3 @@ +-- [REPORT] + +DROP TABLE REPORT; diff --git a/sql/section_drop/23.options.sql b/sql/section_drop/23.options.sql new file mode 100644 index 0000000..69e9714 --- /dev/null +++ b/sql/section_drop/23.options.sql @@ -0,0 +1,3 @@ +-- [OPTIONS] + +DROP TABLE OPTIONS; diff --git a/sql/section_drop/24.coordinates.sql b/sql/section_drop/24.coordinates.sql new file mode 100644 index 0000000..59f9f45 --- /dev/null +++ b/sql/section_drop/24.coordinates.sql @@ -0,0 +1,7 @@ +-- [COORDINATES] + +DROP INDEX COORDINATES_GIST; + +DROP INDEX COORDINATES_SPGIST; + +DROP TABLE COORDINATES; diff --git a/sql/section_drop/25.vertices.sql b/sql/section_drop/25.vertices.sql new file mode 100644 index 0000000..1352d0d --- /dev/null +++ b/sql/section_drop/25.vertices.sql @@ -0,0 +1,3 @@ +-- [VERTICES] + +DROP TABLE VERTICES; diff --git a/sql/section_drop/26.labels.sql b/sql/section_drop/26.labels.sql new file mode 100644 index 0000000..70da104 --- /dev/null +++ b/sql/section_drop/26.labels.sql @@ -0,0 +1,3 @@ +-- [LABELS] + +DROP TABLE LABELS; diff --git a/sql/section_drop/27.backdrop.sql b/sql/section_drop/27.backdrop.sql new file mode 100644 index 0000000..85f3bf2 --- /dev/null +++ b/sql/section_drop/27.backdrop.sql @@ -0,0 +1,3 @@ +-- [BACKDROP] + +DROP TABLE BACKDROP; diff --git a/sql/section_drop/28.end.sql b/sql/section_drop/28.end.sql new file mode 100644 index 0000000..3054ad0 --- /dev/null +++ b/sql/section_drop/28.end.sql @@ -0,0 +1 @@ +-- [END] \ No newline at end of file diff --git a/sql/section_drop/3.reservoirs.sql b/sql/section_drop/3.reservoirs.sql new file mode 100644 index 0000000..4fd1e46 --- /dev/null +++ b/sql/section_drop/3.reservoirs.sql @@ -0,0 +1,3 @@ +-- [RESERVOIRS] + +DROP TABLE RESERVOIRS; diff --git a/sql/section_drop/4.tanks.sql b/sql/section_drop/4.tanks.sql new file mode 100644 index 0000000..f9a4c27 --- /dev/null +++ b/sql/section_drop/4.tanks.sql @@ -0,0 +1,5 @@ +-- [TANKS] + +DROP TABLE TANKS; + +DROP TYPE TANKS_OVERFLOW; diff --git a/sql/section_drop/5.pipes.sql b/sql/section_drop/5.pipes.sql new file mode 100644 index 0000000..e01acd3 --- /dev/null +++ b/sql/section_drop/5.pipes.sql @@ -0,0 +1,5 @@ +-- [PIPES] + +DROP TABLE PIPES; + +DROP TYPE PIPES_STATUS; diff --git a/sql/section_drop/6.pumps.sql b/sql/section_drop/6.pumps.sql new file mode 100644 index 0000000..2526df6 --- /dev/null +++ b/sql/section_drop/6.pumps.sql @@ -0,0 +1,11 @@ +-- [PUMPS] + +DROP TABLE PUMPS_PROPERTY_PATTERN; + +DROP TABLE PUMPS_PROPERTY_HEAD; + +DROP TABLE PUMPS_PROPERTY_SPEED; + +DROP TABLE PUMPS_PROPERTY_POWER; + +DROP TABLE PUMPS; diff --git a/sql/section_drop/7.valves.sql b/sql/section_drop/7.valves.sql new file mode 100644 index 0000000..ca001fe --- /dev/null +++ b/sql/section_drop/7.valves.sql @@ -0,0 +1,5 @@ +-- [VALVES] + +DROP TABLE VALVES; + +DROP TYPE VALVES_TYPE; diff --git a/sql/section_drop/8.tags.sql b/sql/section_drop/8.tags.sql new file mode 100644 index 0000000..78ec688 --- /dev/null +++ b/sql/section_drop/8.tags.sql @@ -0,0 +1,5 @@ +-- [TAGS] + +DROP TABLE TAGS_LINK; + +DROP TABLE TAGS_NODE; diff --git a/sql/section_drop/9.demands.sql b/sql/section_drop/9.demands.sql new file mode 100644 index 0000000..7276cca --- /dev/null +++ b/sql/section_drop/9.demands.sql @@ -0,0 +1,3 @@ +-- [DEMANDS] + +DROP TABLE DEMANDS;