-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.ddl
371 lines (328 loc) · 7.88 KB
/
schema.ddl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
PRAGMA foreign_keys = ON;
create table BioSce
(
biosce int not null
constraint BioSce_pk
primary key
);
create table ClosuresSpe
(
ClosureSce NUMERIC not null,
ClosureId NUMERIC not null,
NodeId NUMERIC not null,
Type TEXT,
Period NUMERIC not null,
Opt NUMERIC,
Closures TEXT
);
create table Config
(
param text not null
constraint Config_pk
primary key,
value text not null
);
create table FleetSce
(
fleetsce int not null
constraint FleetSce_pk
primary key
);
create table GraphSce
(
graphsce int not null
constraint GraphSce_pk
primary key
);
create table Nodes
(
id integer not null,
x numeric not null,
y numeric not null,
hidx integer not null,
code_area integer,
landscape integer,
wind numeric,
salinity numeric,
sst numeric,
nitrogen numeric,
phosphorus numeric,
oxygen numeric,
carbon numeric,
bathymetry numeric,
shipping numeric,
silt numeric,
icesrectanglecode numeric,
benthosbio numeric,
benthosnum numeric,
graphsce integer not null
references GraphSce
on update cascade on delete cascade,
constraint Nodes_pk
primary key (id, graphsce)
);
create table Edges
(
id integer not null
constraint Edges_pk
primary key,
from_node_id integer not null,
to_node_id integer not null,
w integer not null,
graphsce int not null,
foreign key (from_node_id, graphsce) references Nodes
on update cascade on delete cascade,
foreign key (to_node_id, graphsce) references Nodes
on update cascade on delete cascade
);
create unique index Edges_id_uindex
on Edges (id);
create table Populations
(
id integer not null,
name text not null,
biosce integer not null
references BioSce
on update cascade on delete cascade,
constraint pk_Populations
primary key (biosce, id)
);
create table PopulationParameters
(
pop_id int not null,
parameter text not null,
value numeric not null,
biosce int not null,
period text,
country text,
landscape int,
constraint pk_PopulationParameters
primary key (pop_id, biosce, parameter, period, country, landscape),
foreign key (biosce, pop_id) references Populations
on update cascade on delete cascade
);
create index PopulationParameters_parameter_index
on PopulationParameters (parameter);
create table PopulationParametersWithSizeGroupAndAge
(
pop_id int not null,
parameter text not null,
value numeric not null,
biosce int not null,
size_group int,
age int,
period text,
node int,
constraint pk_PopulationParameters
primary key (pop_id, biosce, parameter, size_group, age),
foreign key (biosce, pop_id) references Populations
on update cascade on delete cascade
);
create index PopulationParametersWithSizeGroupAndAge_ByNode_index
on PopulationParametersWithSizeGroupAndAge (pop_id, size_group, age, node);
create table PopulationTransitionMatrix
(
pop int not null,
biosce int not null,
period int,
sizegroup1 int not null,
sizegroup2 int not null,
value numeric
);
create index PopulationTransitionMatrix_index
on PopulationTransitionMatrix (pop, biosce, period);
create table HarboursParameters
(
harbour_name TEXT not null,
node_id integer not null,
parameter text not null,
graphsce integer,
opt1 numeric,
opt2 numeric,
period numeric,
value numeric not null,
constraint HarboursParameters_pk
primary key (harbour_name, node_id, parameter, opt1, opt2, period)
);
create table HarboursParametersWithSpeciesAndMarketCat
(
node_id int not null,
parameter text not null,
value numeric not null,
marketcat int,
period text,
species int
);
create index HarboursParametersWithSpeciesAndMarketCat_ByPop_index
on HarboursParametersWithSpeciesAndMarketCat(node_id, marketcat, species);
create table HarboursParametersWithVesselSize
(
node_id int not null,
parameter text not null,
value numeric not null,
period text,
vesselsize int,
constraint pk_Harbours
primary key (node_id, parameter, period, vesselsize)
);
create table BenthosParameters
(
landscape_id int not null,
parameter text not null,
value numeric not null,
period text,
funcgroup int,
constraint pk_Harbours
primary key (landscape_id, parameter, period, funcgroup)
);
create table MetiersParametersWithLandscape
(
MetierName int not null,
Parameter text not null,
Value numeric not null,
funcgroup int,
Period int,
landscape int,
constraint pk_Metiers
primary key (MetierName, Parameter, funcgroup, Period, landscape)
);
create table MetiersParametersWithSpeciesAndSzGroup
(
MetierName int not null,
Parameter text not null,
Value numeric not null,
fleetsce int not null,
species int,
szgroup int,
Period int
);
create table Scenarios
(
name text not null
constraint Scenarios_pk
primary key,
notes text,
biosce int not null
references BioSce
on update cascade on delete cascade,
fleetsce int not null,
graphsce int not null
references GraphSce
on update cascade on delete cascade
);
create table ScenarioConfig
(
sce TEXT
references Scenarios
on update cascade on delete cascade,
param TEXT not null,
value TEXT
);
create table FishfarmsParameters
(
FishfarmName TEXT not null,
Parameter text not null,
Opt1 numeric,
Opt2 numeric,
Period numeric,
Value numeric not null,
constraint FishfarmsParameters_pk
primary key (FishfarmName, Parameter, Opt1, Opt2, Period)
);
create table FishfarmsSpe
(
FishfarmName TEXT
constraint FishfarmsSpe_pk
primary key
);
create table ShipsParameters
(
ShipName TEXT not null,
Parameter text not null,
Opt1 numeric,
Opt2 numeric,
Period numeric,
Value numeric not null,
constraint ShipsParameters_pk
primary key (ShipName, Parameter, Opt1, Opt2, Period)
);
create table ShipsSpe
(
ShipName TEXT
constraint ShipsSpe_pk
primary key
);
create table FirmsParameters
(
FirmName TEXT not null,
Parameter text not null,
Opt1 numeric,
Opt2 numeric,
Period numeric,
Value numeric not null,
constraint FirmsParameters_pk
primary key (FirmName, Parameter, Opt1, Opt2, Period)
);
create table FirmsSpe
(
FirmName TEXT
constraint FirmsSpe_pk
primary key
);
create table VesselsParameters
(
VesselName TEXT not null,
Parameter text not null,
Opt1 numeric,
Opt2 numeric,
Period numeric,
Value numeric not null,
constraint VesselsParameters_pk
primary key (VesselName, Parameter, Opt1, Opt2, Period)
);
create index VesselsParameters_NameParameterPeriod_index
on VesselsParameters (VesselName, Parameter, Period);
create index VesselsParameters_NameParameter_index
on VesselsParameters (VesselName, Parameter);
create table VesselsSpe
(
fleetsce int not null
references FleetSce
on update cascade on delete cascade,
VesselName TEXT
constraint VesselsSpe_pk
primary key
);
create table MetiersParameters
(
MetierName int not null,
Parameter text not null,
Opt1 numeric,
Opt2 numeric,
Period numeric,
Value numeric not null,
constraint MetiersParameters_pk
primary key (MetierName, Parameter, Opt1, Opt2, Period)
);
create index MetiersParameters_NameParameterPeriod_index
on MetiersParameters (MetierName, Parameter, Period);
create index MetiersParameters_NameParameter_index
on MetiersParameters (MetierName, Parameter);
create table MetiersSpe
(
fleetsce int not null
references FleetSce
on update cascade on delete cascade,
metier_name TEXT
constraint MetiersSpe_pk
primary key,
MetierName int
);
create table HarboursSpe
(
node_id int not null,
harbour_name TEXT,
graphsce int not null
references GraphSce
on update cascade on delete cascade
);