2011-10-08 12:11:02 +02:00
|
|
|
CREATE TABLE category
|
2011-10-08 11:00:42 +02:00
|
|
|
(id text PRIMARY KEY,
|
2011-10-08 12:11:02 +02:00
|
|
|
name text NOT NULL);
|
2011-10-08 11:00:42 +02:00
|
|
|
|
2011-10-08 12:11:02 +02:00
|
|
|
CREATE TABLE placement
|
2011-10-08 11:00:42 +02:00
|
|
|
(id SERIAL PRIMARY KEY,
|
2011-10-08 12:11:02 +02:00
|
|
|
category text NOT NULL REFERENCES category (id),
|
|
|
|
shelf text NOT NULL);
|
2011-10-08 11:00:42 +02:00
|
|
|
|
2011-10-08 12:11:02 +02:00
|
|
|
CREATE TABLE bookseries
|
2011-10-08 11:00:42 +02:00
|
|
|
(id text PRIMARY KEY,
|
2011-10-08 12:11:02 +02:00
|
|
|
title text NOT NULL);
|
2011-10-08 11:00:42 +02:00
|
|
|
|
2011-10-08 12:11:02 +02:00
|
|
|
CREATE TABLE book
|
2011-10-08 11:00:42 +02:00
|
|
|
(isbn text PRIMARY KEY,
|
2011-10-08 12:11:02 +02:00
|
|
|
id text,
|
|
|
|
title text NOT NULL,
|
|
|
|
subtitle text,
|
|
|
|
category text NOT NULL REFERENCES category (id),
|
|
|
|
publisher text,
|
|
|
|
published_year integer,
|
|
|
|
edition text,
|
|
|
|
pages integer,
|
|
|
|
series text REFERENCES bookseries (id),
|
|
|
|
description text); -- TODO: bilde?
|
2011-10-08 11:00:42 +02:00
|
|
|
|
2011-10-08 12:11:02 +02:00
|
|
|
CREATE TABLE alternative_title
|
2011-10-08 11:00:42 +02:00
|
|
|
(id SERIAL PRIMARY KEY,
|
2011-10-08 12:11:02 +02:00
|
|
|
book text NOT NULL REFERENCES book (isbn),
|
|
|
|
alt_title text NOT NULL);
|
2011-10-08 11:00:42 +02:00
|
|
|
|
2011-10-08 12:11:02 +02:00
|
|
|
CREATE TABLE copy
|
|
|
|
(book text REFERENCES book (isbn),
|
|
|
|
number integer,
|
|
|
|
owner text,
|
|
|
|
PRIMARY KEY(book, number));
|
2011-10-08 11:00:42 +02:00
|
|
|
|
|
|
|
CREATE TABLE person
|
|
|
|
(id text PRIMARY KEY,
|
2011-10-08 12:11:02 +02:00
|
|
|
lastname text NOT NULL,
|
|
|
|
firstname text NOT NULL);
|
2011-10-08 11:00:42 +02:00
|
|
|
|
2011-10-08 12:11:02 +02:00
|
|
|
CREATE TABLE bookrole
|
2011-10-08 11:00:42 +02:00
|
|
|
(id text PRIMARY KEY,
|
2011-10-08 12:11:02 +02:00
|
|
|
name text NOT NULL);
|
2011-10-08 11:00:42 +02:00
|
|
|
|
2011-10-08 12:11:02 +02:00
|
|
|
CREATE TABLE bookperson
|
2011-10-08 11:00:42 +02:00
|
|
|
(id SERIAL PRIMARY KEY,
|
2011-10-08 12:11:02 +02:00
|
|
|
book text NOT NULL REFERENCES book (isbn),
|
2011-10-08 11:00:42 +02:00
|
|
|
person text NOT NULL REFERENCES person (id),
|
2011-10-08 12:11:02 +02:00
|
|
|
relation text NOT NULL REFERENCES bookrole (id));
|
2011-10-08 11:00:42 +02:00
|
|
|
|
2011-10-08 12:11:02 +02:00
|
|
|
CREATE TABLE referencetype
|
2011-10-08 11:00:42 +02:00
|
|
|
(id text PRIMARY KEY,
|
2011-10-08 12:11:02 +02:00
|
|
|
name text NOT NULL);
|
2011-10-08 11:00:42 +02:00
|
|
|
|
2011-10-08 12:11:02 +02:00
|
|
|
CREATE TABLE bookreference
|
2011-10-08 11:00:42 +02:00
|
|
|
(id SERIAL PRIMARY KEY,
|
2011-10-08 12:11:02 +02:00
|
|
|
book text NOT NULL REFERENCES book (isbn),
|
|
|
|
reftype text NOT NULL REFERENCES referencetype (id),
|
|
|
|
value text NOT NULL);
|
2011-10-08 11:00:42 +02:00
|
|
|
|
2011-10-08 12:11:02 +02:00
|
|
|
CREATE TABLE personreference
|
2011-10-08 11:00:42 +02:00
|
|
|
(id SERIAL PRIMARY KEY,
|
|
|
|
person text NOT NULL REFERENCES person (id),
|
2011-10-08 12:11:02 +02:00
|
|
|
reftype text NOT NULL REFERENCES referencetype (id),
|
|
|
|
value text NOT NULL);
|