-
Notifications
You must be signed in to change notification settings - Fork 1
/
DashishAnnotatorCreate.sql
164 lines (121 loc) · 4.99 KB
/
DashishAnnotatorCreate.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
--
-- Copyright (C) 2013 DASISH
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
--
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.2.4
-- Dumped by pg_dump version 9.2.2
-- Started on 2013-06-14 14:36:28 CEST
SET client_encoding = 'UTF8';
CREATE DATABASE "DASISHAnnotator" WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'C' LC_CTYPE = 'C';
\connect "DASISHAnnotator"
SET client_encoding = 'UTF8';
SET default_with_oids = false;
SET TIME ZONE LOCAL;
CREATE TABLE access (
access_mode text UNIQUE NOT NULL
);
CREATE TABLE principal (
principal_id SERIAL UNIQUE NOT NULL,
external_id text UNIQUE NOT NULL,
remote_id text UNIQUE NOT NULL,
principal_name text,
e_mail text,
account text NOT NULL
);
CREATE TABLE notebook (
notebook_id SERIAL UNIQUE NOT NULL,
external_id text UNIQUE NOT NULL,
owner_id integer REFERENCES principal(principal_id),
last_modified timestamp default (current_timestamp AT TIME ZONE 'UTC'),
title text
);
CREATE TABLE annotation (
annotation_id SERIAL UNIQUE NOT NULL,
external_id text UNIQUE NOT NULL,
owner_id integer REFERENCES principal(principal_id),
last_modified timestamp default (current_timestamp AT TIME ZONE 'UTC'),
headline text,
body_text text,
body_mimetype text,
is_xml BOOLEAN,
public_ text REFERENCES access(access_mode) NOT NULL default 'none'
);
CREATE TABLE target (
target_id SERIAL UNIQUE NOT NULL,
external_id text UNIQUE NOT NULL,
last_modified timestamp default (current_timestamp AT TIME ZONE 'UTC'),
link_uri text,
version text,
fragment_descriptor text
);
CREATE TABLE cached_representation (
cached_representation_id SERIAL UNIQUE NOT NULL,
external_id text UNIQUE NOT NULL,
mime_type text,
tool text,
type_ text,
file_ bytea
);
-----------------------------------------------------------------------
--------------------- JOINT TABLES ------------------------------------
CREATE TABLE annotations_targets (
annotation_id integer REFERENCES annotation(annotation_id) NOT NULL, -- defining a foreign key: there must be a uniquely defined row in "annotation", that is defined by "annotation_id"
target_id integer REFERENCES target(target_id) NOT NULL,
unique(annotation_id, target_id)
);
CREATE TABLE notebooks_annotations (
notebook_id integer REFERENCES notebook(notebook_id) NOT NULL,
annotation_id integer REFERENCES annotation(annotation_id) NOT NULL,
unique(notebook_id, annotation_id)
);
CREATE TABLE targets_cached_representations (
target_id integer REFERENCES target(target_id) NOT NULL,
cached_representation_id integer REFERENCES cached_representation(cached_representation_id) NOT NULL,
fragment_descriptor_in_cached text,
unique(target_id, cached_representation_id)
);
CREATE TABLE annotations_principals_accesses (
annotation_id integer REFERENCES annotation(annotation_id) NOT NULL,
principal_id integer REFERENCES principal(principal_id) NOT NULL,
access_ text REFERENCES access(access_mode) NOT NULL,
unique(annotation_id, principal_id)
);
CREATE TABLE notebooks_principals_accesses (
notebook_id integer REFERENCES notebook(notebook_id) NOT NULL,
principal_id integer REFERENCES principal(principal_id) NOT NULL,
access_ text REFERENCES access(access_mode) NOT NULL,
unique(notebook_id, principal_id)
);
---------------------------------------------------------------------------------------------
-- ALTER TABLE ONLY annotation
-- ADD CONSTRAINT annotation_primary_key PRIMARY KEY (annotation_id);
-- ALTER TABLE ONLY notebooks_annotations
-- ADD CONSTRAINT pk_notebooks_annotations PRIMARY KEY (notebook_id, annotation_id);
-- ALTER TABLE ONLY annotation
-- ADD CONSTRAINT fk_annotation_owner_principal_id FOREIGN KEY (owner_id) REFERENCES principal(principal_id);
-- ALTER TABLE ONLY notebook
-- ADD CONSTRAINT fk_notebook_owner_id_principal_id FOREIGN KEY (owner_id) REFERENCES principal(principal_id);
--ALTER TABLE ONLY notebooks_annotations
-- ADD CONSTRAINT fk_notebooks_annotations_annotation_id FOREIGN KEY (annotation_id) REFERENCES annotation(annotation_id);
-- ALTER TABLE ONLY notebooks_annotations
-- ADD CONSTRAINT fk_notebooks_annotations_notebook_id FOREIGN KEY (notebook_id) REFERENCES notebook(notebook_id);
-- Completed on 2013-06-14 14:36:28 CEST
--
-- PostgreSQL database dump complete
--