annotate flys-artifacts/doc/conf/datacage.sql @ 983:4ea5f5a2284e

Ajusted datacage to use the SQL infrastructure from the artifact database. flys-artifacts/trunk@2413 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 28 Jul 2011 13:32:27 +0000
parents 799c7108ea6d
children 8094ba4ab873
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
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 CREATE TABLE users (
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 id IDENTITY PRIMARY KEY NOT NULL,
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 gid UUID NOT NULL UNIQUE
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 );
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 CREATE TABLE collections (
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 id IDENTITY PRIMARY KEY NOT NULL,
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 gid UUID NOT NULL UNIQUE,
980
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
11 user_id INT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
979
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 name VARCHAR(256) NOT NULL
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 );
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 CREATE TABLE artifacts (
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 id IDENTITY PRIMARY KEY NOT NULL,
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 gid UUID NOT NULL UNIQUE,
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 state VARCHAR(256) NOT NULL
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 );
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 CREATE TABLE collection_items (
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 id IDENTITY PRIMARY KEY NOT NULL,
980
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
23 collection_id INT NOT NULL REFERENCES collections(id) ON DELETE CASCADE,
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
24 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
25 );
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 CREATE TABLE artifact_data (
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 id IDENTITY PRIMARY KEY NOT NULL,
980
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
29 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
30 k VARCHAR(256) NOT NULL,
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 v VARCHAR(256), -- Maybe too short
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 UNIQUE (artifact_id, k)
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 );
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34
981
799c7108ea6d datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 980
diff changeset
35 CREATE TABLE outs (
799c7108ea6d datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 980
diff changeset
36 id IDENTITY PRIMARY KEY NOT NULL,
799c7108ea6d datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 980
diff changeset
37 artifact_id INT NOT NULL REFERENCES artifacts(id) ON DELETE CASCADE,
799c7108ea6d datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 980
diff changeset
38 name VARCHAR(256) NOT NULL,
799c7108ea6d datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 980
diff changeset
39 description VARCHAR(256),
799c7108ea6d datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 980
diff changeset
40 out_type VARCHAR(256)
799c7108ea6d datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 980
diff changeset
41 );
799c7108ea6d datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 980
diff changeset
42
979
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 CREATE TABLE facets (
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 id IDENTITY PRIMARY KEY NOT NULL,
980
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
45 artifact_id INT NOT NULL REFERENCES artifacts(id) ON DELETE CASCADE,
981
799c7108ea6d datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 980
diff changeset
46 out_id INT NOT NULL REFERENCES outs(id) ON DELETE CASCADE,
979
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 name VARCHAR(256) NOT NULL,
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 num INT NOT NULL,
980
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
49 state VARCHAR(256) NOT NULL,
979
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 description VARCHAR(256),
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 UNIQUE (artifact_id, output, num, name)
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 );
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53
980
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
54 -- DROP TABLE facets;
981
799c7108ea6d datacage: prepared access to outs of artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 980
diff changeset
55 -- DROP TABLE outs;
980
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
56 -- DROP TABLE artifact_data;
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
57 -- DROP TABLE collection_items;
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
58 -- DROP TABLE collections;
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
59 -- DROP TABLE artifacts;
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
60 -- DROP TABLE users;
f9a6a9cd918e Datacage: Added ON DELETE CASCADE constraints in schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 979
diff changeset
61
979
2306340d7540 Added schema for datacage db
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 COMMIT;

http://dive4elements.wald.intevation.org