diff flys-artifacts/doc/conf/datacage.sql @ 979:2306340d7540

Added schema for datacage db flys-artifacts/trunk@2406 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 26 Jul 2011 14:14:55 +0000
parents
children f9a6a9cd918e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/doc/conf/datacage.sql	Tue Jul 26 14:14:55 2011 +0000
@@ -0,0 +1,45 @@
+BEGIN;
+
+CREATE TABLE users (
+    id  IDENTITY PRIMARY KEY NOT NULL,
+    gid UUID                 NOT NULL UNIQUE
+);
+
+CREATE TABLE collections (
+    id      IDENTITY PRIMARY KEY NOT NULL,
+    gid     UUID                 NOT NULL UNIQUE,
+    user_id INT                  NOT NULL REFERENCES users(id),
+    name    VARCHAR(256)         NOT NULL
+);
+
+CREATE TABLE artifacts (
+    id    IDENTITY PRIMARY KEY NOT NULL,
+    gid   UUID                 NOT NULL UNIQUE,
+    state VARCHAR(256)         NOT NULL
+);
+
+CREATE TABLE collection_items (
+    id            IDENTITY PRIMARY KEY NOT NULL,
+    collection_id INT                  NOT NULL REFERENCES collections(id),
+    artifact_id   INT                  NOT NULL REFERENCES artifacts(id)
+);
+
+CREATE TABLE artifact_data (
+    id          IDENTITY PRIMARY KEY NOT NULL,
+    artifact_id INT                  NOT NULL REFERENCES artifacts(id),
+    k           VARCHAR(256)         NOT NULL,
+    v           VARCHAR(256),         -- Maybe too short
+    UNIQUE (artifact_id, k)
+);
+
+CREATE TABLE facets (
+    id          IDENTITY PRIMARY KEY NOT NULL,
+    artifact_id INT                  NOT NULL REFERENCES artifacts(id),
+    name        VARCHAR(256)         NOT NULL,
+    num         INT                  NOT NULL,
+    output      VARCHAR(256)         NOT NULL,
+    description VARCHAR(256),
+    UNIQUE (artifact_id, output, num, name)
+);
+
+COMMIT;

http://dive4elements.wald.intevation.org