diff artifact-database/doc/schema-h2.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-h2.sql	Tue Mar 01 16:07:25 2011 +0000
+++ b/artifact-database/doc/schema-h2.sql	Tue Mar 01 16:26:27 2011 +0000
@@ -18,4 +18,34 @@
     data        BINARY
 );
 
+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