Mercurial > dive4elements > framework
view artifact-database/doc/schema-pg.sql @ 122:c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
artifacts/trunk@1345 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 01 Mar 2011 16:31:52 +0000 |
parents | 720d65bbba13 |
children | caf9f456f7e3 |
line wrap: on
line source
-- -- schema to store artifacts in PostgreSQL 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 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;