Mercurial > dive4elements > river
annotate flys-artifacts/doc/conf/datacage.sql @ 1039:cf39205df113
Part of refactoring (see next commit).
flys-artifacts/trunk@2500 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 17 Aug 2011 13:04:53 +0000 |
parents | 02c327ffbad7 |
children | a007a4368768 |
rev | line source |
---|---|
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 BEGIN; |
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
3 CREATE SEQUENCE USERS_ID_SEQ; |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
4 |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 CREATE TABLE users ( |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
6 id INT PRIMARY KEY NOT NULL, |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
7 gid UUID NOT NULL UNIQUE |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 ); |
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
10 CREATE SEQUENCE COLLECTIONS_ID_SEQ; |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
11 |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 CREATE TABLE collections ( |
1025
02c327ffbad7
Datacage: Extended schema for artifacts and collections
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
993
diff
changeset
|
13 id INT PRIMARY KEY NOT NULL, |
02c327ffbad7
Datacage: Extended schema for artifacts and collections
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
993
diff
changeset
|
14 gid UUID NOT NULL UNIQUE, |
02c327ffbad7
Datacage: Extended schema for artifacts and collections
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
993
diff
changeset
|
15 user_id INT NOT NULL REFERENCES users(id) ON DELETE CASCADE, |
02c327ffbad7
Datacage: Extended schema for artifacts and collections
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
993
diff
changeset
|
16 name VARCHAR(256) NOT NULL, |
02c327ffbad7
Datacage: Extended schema for artifacts and collections
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
993
diff
changeset
|
17 creation TIMESTAMP NOT NULL |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 ); |
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
20 CREATE SEQUENCE ARTIFACTS_ID_SEQ; |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
21 |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 CREATE TABLE artifacts ( |
1025
02c327ffbad7
Datacage: Extended schema for artifacts and collections
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
993
diff
changeset
|
23 id INT PRIMARY KEY NOT NULL, |
02c327ffbad7
Datacage: Extended schema for artifacts and collections
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
993
diff
changeset
|
24 gid UUID NOT NULL UNIQUE, |
02c327ffbad7
Datacage: Extended schema for artifacts and collections
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
993
diff
changeset
|
25 state VARCHAR(256) NOT NULL, |
02c327ffbad7
Datacage: Extended schema for artifacts and collections
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
993
diff
changeset
|
26 creation TIMESTAMP NOT NULL |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 ); |
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
985
diff
changeset
|
29 CREATE SEQUENCE COLLECTION_ITEMS_ID_SEQ; |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
30 |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 CREATE TABLE collection_items ( |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
32 id INT PRIMARY KEY NOT NULL, |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
33 collection_id INT NOT NULL REFERENCES collections(id) ON DELETE CASCADE, |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
34 artifact_id INT NOT NULL REFERENCES artifacts(id) ON DELETE CASCADE |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 ); |
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
37 CREATE SEQUENCE ARTIFACT_DATA_ID_SEQ; |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
38 |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 CREATE TABLE artifact_data ( |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
40 id INT PRIMARY KEY NOT NULL, |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
41 artifact_id INT NOT NULL REFERENCES artifacts(id) ON DELETE CASCADE, |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
42 kind VARCHAR(256) NOT NULL, |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
43 k VARCHAR(256) NOT NULL, |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
44 v VARCHAR(256), -- Maybe too short |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 UNIQUE (artifact_id, k) |
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 ); |
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
48 CREATE SEQUENCE OUTS_ID_SEQ; |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
49 |
981
799c7108ea6d
datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
980
diff
changeset
|
50 CREATE TABLE outs ( |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
51 id INT PRIMARY KEY NOT NULL, |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
52 artifact_id INT NOT NULL REFERENCES artifacts(id) ON DELETE CASCADE, |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
53 name VARCHAR(256) NOT NULL, |
981
799c7108ea6d
datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
980
diff
changeset
|
54 description VARCHAR(256), |
799c7108ea6d
datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
980
diff
changeset
|
55 out_type VARCHAR(256) |
799c7108ea6d
datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
980
diff
changeset
|
56 ); |
799c7108ea6d
datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
980
diff
changeset
|
57 |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
58 CREATE SEQUENCE FACETS_ID_SEQ; |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
59 |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 CREATE TABLE facets ( |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
61 id INT PRIMARY KEY NOT NULL, |
992
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
62 out_id INT NOT NULL REFERENCES outs(id) ON DELETE CASCADE, |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
63 name VARCHAR(256) NOT NULL, |
992
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
64 num INT NOT NULL, |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
65 state VARCHAR(256) NOT NULL, |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 description VARCHAR(256), |
993
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
67 UNIQUE (out_id, num, name) |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 ); |
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
70 -- DROP SEQUENCE USERS_ID_SEQ; |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
71 -- DROP SEQUENCE COLLECTIONS_ID_SEQ; |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
72 -- DROP SEQUENCE ARTIFACTS_ID_SEQ; |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
985
diff
changeset
|
73 -- DROP SEQUENCE COLLECTION_ITEMS_ID_SEQ; |
985
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
74 -- DROP SEQUENCE ARTIFACT_DATA_ID_SEQ; |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
75 -- DROP SEQUENCE OUTS_ID_SEQ; |
8094ba4ab873
Datacage SQL schema: Using sequences for id generation now
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
981
diff
changeset
|
76 -- DROP SEQUENCE FACETS_ID_SEQ; |
980
f9a6a9cd918e
Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
979
diff
changeset
|
77 -- DROP TABLE facets; |
981
799c7108ea6d
datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
980
diff
changeset
|
78 -- DROP TABLE outs; |
980
f9a6a9cd918e
Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
979
diff
changeset
|
79 -- DROP TABLE artifact_data; |
f9a6a9cd918e
Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
979
diff
changeset
|
80 -- DROP TABLE collection_items; |
f9a6a9cd918e
Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
979
diff
changeset
|
81 -- DROP TABLE collections; |
f9a6a9cd918e
Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
979
diff
changeset
|
82 -- DROP TABLE artifacts; |
f9a6a9cd918e
Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
979
diff
changeset
|
83 -- DROP TABLE users; |
f9a6a9cd918e
Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
979
diff
changeset
|
84 |
979
2306340d7540
Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 COMMIT; |