Mercurial > dive4elements > framework
view artifact-database/doc/schema-h2.sql @ 181:116482169b44
Adapted the sql statements for fetching all collections and all user collections from database.
artifacts/trunk@1407 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 07 Mar 2011 11:10:45 +0000 |
parents | a76de72ad6d1 |
children | a85d889a1b0d |
line wrap: on
line source
-- -- schema to store artifacts in H2 databases. -- BEGIN; -- not using AUTO_INCREMENT to be more compatible with -- other dbms. CREATE SEQUENCE ARTIFACTS_ID_SEQ; CREATE TABLE artifacts ( id INT PRIMARY KEY NOT NULL, gid UUID NOT NULL UNIQUE, creation TIMESTAMP NOT NULL, last_access TIMESTAMP NOT NULL, ttl BIGINT, -- NULL means eternal factory VARCHAR(256) NOT NULL, data BINARY ); CREATE SEQUENCE USERS_ID_SEQ; CREATE TABLE users ( id INT PRIMARY KEY NOT NULL, gid UUID NOT NULL UNIQUE, 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 UNIQUE, 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), attribute BINARY, UNIQUE (collection_id, artifact_id) ); COMMIT;