Figure out references
This commit is contained in:
@@ -9,3 +9,5 @@ create table status
|
|||||||
, setting numeric
|
, setting numeric
|
||||||
, check (status is not null or setting is not null)
|
, check (status is not null or setting is not null)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- ddelete when delete link
|
||||||
|
|||||||
@@ -19,14 +19,20 @@ create table energy_pump_price
|
|||||||
, price numeric not null
|
, price numeric not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete pump
|
||||||
|
|
||||||
create table energy_pump_pattern
|
create table energy_pump_pattern
|
||||||
(
|
(
|
||||||
pump varchar(32) primary key references pumps(id) not null
|
pump varchar(32) primary key references pumps(id) not null
|
||||||
, pattern varchar(32) references _pattern(id) not null
|
, pattern varchar(32) references _pattern(id) not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete pump
|
||||||
|
|
||||||
create table energy_pump_effic
|
create table energy_pump_effic
|
||||||
(
|
(
|
||||||
pump varchar(32) primary key references pumps(id) not null
|
pump varchar(32) primary key references pumps(id) not null
|
||||||
, effic varchar(32) references _curve(id) not null
|
, effic varchar(32) references _curve(id) not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete pump
|
||||||
|
|||||||
@@ -5,3 +5,5 @@ create table emitters
|
|||||||
junction varchar(32) primary key references junctions(id)
|
junction varchar(32) primary key references junctions(id)
|
||||||
, coefficient numeric not null
|
, coefficient numeric not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete junction
|
||||||
|
|||||||
@@ -5,3 +5,5 @@ create table quality
|
|||||||
node varchar(32) primary key references _node(id)
|
node varchar(32) primary key references _node(id)
|
||||||
, quality numeric not null
|
, quality numeric not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete ndoe
|
||||||
|
|||||||
@@ -9,3 +9,6 @@ create table sources
|
|||||||
, strength numeric not null
|
, strength numeric not null
|
||||||
, pattern varchar(32) references _pattern(id)
|
, pattern varchar(32) references _pattern(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete node
|
||||||
|
-- unset pattern when delete pattern
|
||||||
|
|||||||
@@ -22,14 +22,20 @@ create table reactions_pipe_bulk
|
|||||||
, value numeric not null
|
, value numeric not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete pipe
|
||||||
|
|
||||||
create table reactions_pipe_wall
|
create table reactions_pipe_wall
|
||||||
(
|
(
|
||||||
pipe varchar(32) primary key references pipes(id) not null
|
pipe varchar(32) primary key references pipes(id) not null
|
||||||
, value numeric not null
|
, value numeric not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete pipe
|
||||||
|
|
||||||
create table reactions_tank
|
create table reactions_tank
|
||||||
(
|
(
|
||||||
tank varchar(32) primary key references tanks(id) not null
|
tank varchar(32) primary key references tanks(id) not null
|
||||||
, value numeric not null
|
, value numeric not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete tank
|
||||||
|
|||||||
@@ -7,3 +7,5 @@ create table junctions
|
|||||||
, demand numeric
|
, demand numeric
|
||||||
, pattern varchar(32) references _pattern(id)
|
, pattern varchar(32) references _pattern(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- unset pattern when delete pattern
|
||||||
|
|||||||
@@ -8,3 +8,5 @@ create table mixing
|
|||||||
, model mixing_model not null
|
, model mixing_model not null
|
||||||
, value numeric
|
, value numeric
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete tank
|
||||||
|
|||||||
@@ -6,5 +6,7 @@ create table coordinates
|
|||||||
, coord point not null
|
, coord point not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete node
|
||||||
|
|
||||||
create index coordinates_spgist on coordinates using spgist(coord);
|
create index coordinates_spgist on coordinates using spgist(coord);
|
||||||
create index coordinates_gist on coordinates using gist(coord);
|
create index coordinates_gist on coordinates using gist(coord);
|
||||||
|
|||||||
@@ -7,3 +7,5 @@ create table vertices
|
|||||||
, x numeric not null
|
, x numeric not null
|
||||||
, y numeric not null
|
, y numeric not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete link
|
||||||
|
|||||||
@@ -8,3 +8,5 @@ create table labels
|
|||||||
, node varchar(32) references _node(id)
|
, node varchar(32) references _node(id)
|
||||||
, primary key (x, y)
|
, primary key (x, y)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- unset node when delete node
|
||||||
|
|||||||
@@ -6,3 +6,5 @@ create table reservoirs
|
|||||||
, head numeric not null
|
, head numeric not null
|
||||||
, pattern varchar(32) references _pattern(id)
|
, pattern varchar(32) references _pattern(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- unset pattern when delete pattern
|
||||||
|
|||||||
@@ -14,3 +14,5 @@ create table tanks
|
|||||||
, vol_curve varchar(32) references _curve(id)
|
, vol_curve varchar(32) references _curve(id)
|
||||||
, overflow tanks_overflow
|
, overflow tanks_overflow
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- unset vol_curve when delete curve
|
||||||
|
|||||||
@@ -14,3 +14,6 @@ create table pipes
|
|||||||
, status pipes_status not null
|
, status pipes_status not null
|
||||||
, check (node1 <> node2)
|
, check (node1 <> node2)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete node1
|
||||||
|
-- delete when delete node2
|
||||||
|
|||||||
@@ -12,3 +12,8 @@ create table pumps
|
|||||||
, check (power is not null or head is not null)
|
, check (power is not null or head is not null)
|
||||||
, check ((power is not null and head is not null) is false)
|
, check ((power is not null and head is not null) is false)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete node1
|
||||||
|
-- delete when delete node2
|
||||||
|
-- unset head when delete curve
|
||||||
|
-- unset pattern when delete pattern
|
||||||
|
|||||||
@@ -12,3 +12,6 @@ create table valves
|
|||||||
, setting numeric not null
|
, setting numeric not null
|
||||||
, minor_loss numeric not null
|
, minor_loss numeric not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete node1
|
||||||
|
-- delete when delete node2
|
||||||
|
|||||||
@@ -6,8 +6,12 @@ create table tags_node
|
|||||||
, tag text not null
|
, tag text not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete node
|
||||||
|
|
||||||
create table tags_link
|
create table tags_link
|
||||||
(
|
(
|
||||||
id varchar(32) primary key references _link(id)
|
id varchar(32) primary key references _link(id)
|
||||||
, tag text not null
|
, tag text not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete link
|
||||||
|
|||||||
@@ -8,3 +8,6 @@ create table demands
|
|||||||
, pattern varchar(32) references _pattern(id)
|
, pattern varchar(32) references _pattern(id)
|
||||||
, category text
|
, category text
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- delete when delete junction
|
||||||
|
-- unset pattern when delete pattern
|
||||||
|
|||||||
Reference in New Issue
Block a user