diff artifact-database/doc/schema-pg.sql @ 121:720d65bbba13

Extended db scheme to cope with collections, collection items and users. artifacts/trunk@1344 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 01 Mar 2011 16:26:27 +0000
parents 5e4bc24ea438
children caf9f456f7e3
line wrap: on
line diff
--- a/artifact-database/doc/schema-pg.sql	Tue Mar 01 16:07:25 2011 +0000
+++ b/artifact-database/doc/schema-pg.sql	Tue Mar 01 16:26:27 2011 +0000
@@ -18,4 +18,34 @@
     data        bytea
 );
 
+CREATE SEQUENCE USERS_ID_SEQ;
+
+CREATE TABLE users (
+    id   int PRIMARY KEY NOT NULL,
+    gid  uuid            NOT NULL,
+    name VARCHAR(256)    NOT NULL UNIQUE,
+    role BINARY
+);
+
+CREATE SEQUENCE COLLECTIONS_ID_SEQ;
+
+CREATE TABLE collections (
+    id          int PRIMARY KEY NOT NULL,
+    gid         uuid            NOT NULL,
+    name VARCHAR(256)           NOT NULL,
+    owner_id    int             NOT NULL REFERENCES users(id),
+    creation    timestamp       NOT NULL,
+    last_access timestamp       NOT NULL,
+    ttl         bigint, -- NULL means eternal
+);
+
+CREATE SEQUENCE COLLECTION_ITEMS_SEQ;
+
+CREATE TABLE collection_items (
+    id            int PRIMARY KEY NOT NULL,
+    collection_id int             NOT NULL REFERENCES collections(id),
+    artifact_id   int             NOT NULL REFERENCES artifacts(id),
+    UNIQUE (collection_id, artifact_id)
+);
+
 COMMIT;

http://dive4elements.wald.intevation.org