1 |
4104
|
daigle
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Copyright: 2004 Regents of the University of California and the
|
4 |
|
|
* National Center for Ecological Analysis and Synthesis
|
5 |
|
|
*
|
6 |
|
|
* '$Author$'
|
7 |
|
|
* '$Date$'
|
8 |
|
|
* '$Revision$'
|
9 |
|
|
*
|
10 |
|
|
* This program is free software; you can redistribute it and/or modify
|
11 |
|
|
* it under the terms of the GNU General Public License as published by
|
12 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
13 |
|
|
* (at your option) any later version.
|
14 |
|
|
*
|
15 |
|
|
* This program is distributed in the hope that it will be useful,
|
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
* GNU General Public License for more details.
|
19 |
|
|
*
|
20 |
|
|
* You should have received a copy of the GNU General Public License
|
21 |
|
|
* along with this program; if not, write to the Free Software
|
22 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23 |
|
|
*/
|
24 |
|
|
|
25 |
|
|
/*
|
26 |
|
|
* Drop all of the objects in proper order
|
27 |
|
|
*/
|
28 |
|
|
set echo off
|
29 |
|
|
|
30 |
|
|
DROP SEQUENCE xml_nodes_id_seq;
|
31 |
|
|
DROP SEQUENCE xml_revisions_id_seq;
|
32 |
|
|
DROP SEQUENCE xml_catalog_id_seq;
|
33 |
|
|
DROP SEQUENCE xml_relation_id_seq;
|
34 |
|
|
DROP SEQUENCE xml_replication_id_seq;
|
35 |
|
|
DROP SEQUENCE access_log_id_seq;
|
36 |
|
|
DROP SEQUENCE xml_returnfield_id_seq;
|
37 |
|
|
DROP SEQUENCE xml_queryresult_id_seq;
|
38 |
|
|
DROP SEQUENCE xml_path_index_id_seq;
|
39 |
|
|
DROP SEQUENCE db_version_id_seq;
|
40 |
|
|
|
41 |
|
|
/* Drop triggers are not necessary */
|
42 |
|
|
DROP TRIGGER xml_nodes_before_insert;
|
43 |
|
|
DROP TRIGGER xml_revisions_before_insert;
|
44 |
|
|
DROP TRIGGER xml_catalog_before_insert;
|
45 |
|
|
DROP TRIGGER xml_relation_before_insert;
|
46 |
|
|
DROP TRIGGER xml_replication_before_insert;
|
47 |
|
|
DROP TRIGGER access_log_before_insert;
|
48 |
|
|
DROP TRIGGER xml_returnfield_before_insert;
|
49 |
|
|
DROP TRIGGER xml_queryresult_before_insert;
|
50 |
|
|
DROP TRIGGER db_version_before_insert;
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
DROP TABLE xml_index;
|
54 |
|
|
DROP TABLE xml_access;
|
55 |
|
|
DROP TABLE xml_accesssubtree;
|
56 |
|
|
DROP TABLE xml_revisions;
|
57 |
|
|
DROP TABLE xml_relation;
|
58 |
|
|
DROP TABLE xml_documents CASCADE CONSTRAINTS;
|
59 |
|
|
DROP TABLE xml_nodes;
|
60 |
|
|
DROP TABLE xml_nodes_revisions;
|
61 |
|
|
DROP TABLE xml_replication;
|
62 |
|
|
DROP TABLE xml_catalog;
|
63 |
|
|
DROP TABLE identifier;
|
64 |
5371
|
berkley
|
DROP TABLE systemMetadata;
|
65 |
4104
|
daigle
|
DROP TABLE access_log;
|
66 |
|
|
DROP TABLE harvest_site_schedule;
|
67 |
|
|
DROP TABLE harvest_detail_log;
|
68 |
|
|
DROP TABLE harvest_log;
|
69 |
|
|
DROP TABLE xml_queryresult;
|
70 |
|
|
DROP TABLE xml_returnfield;
|
71 |
|
|
DROP TABLE xml_path_index;
|
72 |
|
|
DROP TABLE db_version;
|
73 |
|
|
|
74 |
|
|
/*
|
75 |
|
|
*Replication -- table to store servers that metacat is replicated to
|
76 |
|
|
*/
|
77 |
|
|
CREATE TABLE xml_replication (
|
78 |
|
|
serverid NUMBER(20),
|
79 |
|
|
server VARCHAR2(512),
|
80 |
|
|
last_checked DATE,
|
81 |
|
|
replicate NUMBER(1),
|
82 |
|
|
datareplicate NUMBER(1),
|
83 |
|
|
hub NUMBER(1),
|
84 |
|
|
CONSTRAINT xml_replication_pk PRIMARY KEY (serverid)
|
85 |
|
|
);
|
86 |
|
|
|
87 |
|
|
CREATE SEQUENCE xml_replication_id_seq;
|
88 |
|
|
CREATE TRIGGER xml_replication_before_insert
|
89 |
|
|
BEFORE INSERT ON xml_replication FOR EACH ROW
|
90 |
|
|
BEGIN
|
91 |
|
|
SELECT xml_replication_id_seq.nextval
|
92 |
|
|
INTO :new.serverid
|
93 |
|
|
FROM dual;
|
94 |
|
|
END;
|
95 |
|
|
/
|
96 |
|
|
|
97 |
6814
|
leinfelder
|
INSERT INTO xml_replication (server, replicate, datareplicate, hub)
|
98 |
|
|
VALUES ('localhost', '0', '0', '0');
|
99 |
4104
|
daigle
|
|
100 |
|
|
/*
|
101 |
|
|
* Nodes -- table to store XML Nodes (both elements and attributes)
|
102 |
|
|
*/
|
103 |
|
|
CREATE SEQUENCE xml_nodes_id_seq;
|
104 |
|
|
CREATE TABLE xml_nodes (
|
105 |
|
|
nodeid NUMBER(20), -- the unique node id (pk)
|
106 |
|
|
nodeindex NUMBER(10), -- order of nodes within parent
|
107 |
|
|
nodetype VARCHAR2(20), -- type (DOCUMENT, COMMENT, PI,
|
108 |
|
|
-- ELEMENT, ATTRIBUTE, TEXT)
|
109 |
|
|
nodename VARCHAR2(250), -- the name of an element or attribute
|
110 |
|
|
nodeprefix VARCHAR2(50), -- the namespace prefix of an element
|
111 |
|
|
-- or attribute
|
112 |
|
|
nodedata VARCHAR2(4000), -- the data for this node (e.g.,
|
113 |
|
|
-- for TEXT it is the content)
|
114 |
|
|
parentnodeid NUMBER(20), -- index of the parent of this node
|
115 |
|
|
rootnodeid NUMBER(20), -- index of the root node of this tree
|
116 |
|
|
docid VARCHAR2(250), -- index to the document id
|
117 |
|
|
date_created DATE,
|
118 |
|
|
date_updated DATE,
|
119 |
6012
|
leinfelder
|
nodedatanumerical NUMBER, -- the data for this node if it is a number
|
120 |
|
|
nodedatadate TIMESTAMP, -- the data for this node if it is a date
|
121 |
4104
|
daigle
|
CONSTRAINT xml_nodes_pk PRIMARY KEY (nodeid),
|
122 |
|
|
CONSTRAINT xml_nodes_root_fk
|
123 |
|
|
FOREIGN KEY (rootnodeid) REFERENCES xml_nodes,
|
124 |
|
|
CONSTRAINT xml_nodes_parent_fk
|
125 |
|
|
FOREIGN KEY (parentnodeid) REFERENCES xml_nodes
|
126 |
|
|
);
|
127 |
|
|
CREATE TRIGGER xml_nodes_before_insert
|
128 |
|
|
BEFORE INSERT ON xml_nodes FOR EACH ROW
|
129 |
|
|
BEGIN
|
130 |
|
|
SELECT xml_nodes_id_seq.nextval
|
131 |
|
|
INTO :new.nodeid
|
132 |
|
|
FROM dual;
|
133 |
|
|
END;
|
134 |
|
|
/
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
/*
|
138 |
|
|
* Indexes of rootnodeid, parentnodeid, and nodename in xml_nodes
|
139 |
|
|
*/
|
140 |
|
|
CREATE INDEX xml_nodes_idx1 ON xml_nodes (rootnodeid);
|
141 |
|
|
CREATE INDEX xml_nodes_idx2 ON xml_nodes (parentnodeid);
|
142 |
|
|
CREATE INDEX xml_nodes_idx3 ON xml_nodes (nodename);
|
143 |
|
|
CREATE INDEX xml_nodes_idx4 ON xml_nodes (docid);
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
/*
|
147 |
|
|
* xml_nodes_revisions -- table to store nodes from xml_nodes which are of old revisions and deleted document
|
148 |
|
|
*/
|
149 |
|
|
|
150 |
|
|
CREATE TABLE xml_nodes_revisions (
|
151 |
|
|
nodeid NUMBER(20), -- the unique node id (pk)
|
152 |
|
|
nodeindex NUMBER(10), -- order of nodes within parent
|
153 |
|
|
nodetype VARCHAR2(20), -- type (DOCUMENT, COMMENT, PI,
|
154 |
|
|
-- ELEMENT, ATTRIBUTE, TEXT)
|
155 |
|
|
nodename VARCHAR2(250), -- the name of an element or attribute
|
156 |
|
|
nodeprefix VARCHAR2(50), -- the namespace prefix of an element
|
157 |
|
|
-- or attribute
|
158 |
|
|
nodedata VARCHAR2(4000), -- the data for this node (e.g.,
|
159 |
|
|
-- for TEXT it is the content)
|
160 |
|
|
parentnodeid NUMBER(20), -- index of the parent of this node
|
161 |
|
|
rootnodeid NUMBER(20), -- index of the root node of this tree
|
162 |
|
|
docid VARCHAR2(250), -- index to the document id
|
163 |
|
|
date_created DATE,
|
164 |
|
|
date_updated DATE,
|
165 |
6012
|
leinfelder
|
nodedatanumerical NUMBER, -- the data for this node if it is a number
|
166 |
|
|
nodedatadate TIMESTAMP, -- the data for this node if it is a date
|
167 |
4104
|
daigle
|
CONSTRAINT xml_nodes_revisions_pk PRIMARY KEY (nodeid),
|
168 |
|
|
CONSTRAINT xml_nodes_revisions_root_fk
|
169 |
|
|
FOREIGN KEY (rootnodeid) REFERENCES xml_nodes_revisions,
|
170 |
|
|
CONSTRAINT xml_nodes_revisions_parent_fk
|
171 |
|
|
FOREIGN KEY (parentnodeid) REFERENCES xml_nodes_revisions
|
172 |
|
|
);
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
/*
|
176 |
|
|
* Indexes of rootnodeid, parentnodeid, and nodename in xml_nodes_revision
|
177 |
|
|
*/
|
178 |
|
|
CREATE INDEX xml_nodes_revisions_idx1 ON xml_nodes_revisions (rootnodeid);
|
179 |
|
|
CREATE INDEX xml_nodes_revisions_idx2 ON xml_nodes_revisions (parentnodeid);
|
180 |
|
|
CREATE INDEX xml_nodes_revisions_idx3 ON xml_nodes_revisions (nodename);
|
181 |
|
|
|
182 |
|
|
/*
|
183 |
|
|
* XML Catalog -- table to store all external sources for XML documents
|
184 |
|
|
*/
|
185 |
|
|
CREATE TABLE xml_catalog (
|
186 |
|
|
catalog_id NUMBER(20), -- the id for this catalog entry
|
187 |
|
|
entry_type VARCHAR2(500), -- the type of this catalog entry
|
188 |
|
|
-- (e.g., DTD, XSD, XSL)
|
189 |
|
|
source_doctype VARCHAR2(500), -- the source public_id for transforms
|
190 |
|
|
target_doctype VARCHAR2(500), -- the target public_id for transforms
|
191 |
|
|
public_id VARCHAR2(500), -- the unique id for this type
|
192 |
|
|
system_id VARCHAR2(1000), -- the local location of the object
|
193 |
|
|
CONSTRAINT xml_catalog_pk PRIMARY KEY (catalog_id),
|
194 |
|
|
CONSTRAINT xml_catalog_uk UNIQUE
|
195 |
|
|
(entry_type, source_doctype, target_doctype, public_id)
|
196 |
|
|
);
|
197 |
|
|
|
198 |
|
|
CREATE SEQUENCE xml_catalog_id_seq;
|
199 |
|
|
|
200 |
|
|
CREATE TRIGGER xml_catalog_before_insert
|
201 |
|
|
BEFORE INSERT ON xml_catalog FOR EACH ROW
|
202 |
|
|
BEGIN
|
203 |
|
|
SELECT xml_catalog_id_seq.nextval
|
204 |
|
|
INTO :new.catalog_id
|
205 |
|
|
FROM dual;
|
206 |
|
|
END;
|
207 |
|
|
/
|
208 |
|
|
|
209 |
|
|
/*
|
210 |
|
|
* Documents -- table to store XML documents
|
211 |
|
|
*/
|
212 |
|
|
CREATE TABLE xml_documents (
|
213 |
|
|
docid VARCHAR2(250), -- the document id #
|
214 |
|
|
rootnodeid NUMBER(20), -- reference to root node of the DOM
|
215 |
|
|
docname VARCHAR2(100), -- usually the root element name
|
216 |
|
|
doctype VARCHAR2(100), -- public id indicating document type
|
217 |
|
|
user_owner VARCHAR2(100), -- the user owned the document
|
218 |
|
|
user_updated VARCHAR2(100), -- the user updated the document
|
219 |
|
|
server_location NUMBER(20), -- the server on which this document
|
220 |
|
|
-- originates
|
221 |
|
|
rev NUMBER(10) DEFAULT 1,--the revision number of the docume
|
222 |
|
|
date_created DATE,
|
223 |
|
|
date_updated DATE,
|
224 |
|
|
public_access NUMBER(1), -- flag for public access
|
225 |
|
|
catalog_id NUMBER(20), -- reference to xml_catalog
|
226 |
|
|
CONSTRAINT xml_documents_pk PRIMARY KEY (docid),
|
227 |
|
|
CONSTRAINT xml_documents_rep_fk
|
228 |
|
|
FOREIGN KEY (server_location) REFERENCES xml_replication,
|
229 |
|
|
CONSTRAINT xml_documents_root_fk
|
230 |
|
|
FOREIGN KEY (rootnodeid) REFERENCES xml_nodes,
|
231 |
|
|
CONSTRAINT xml_documents_catalog_fk
|
232 |
|
|
FOREIGN KEY (catalog_id) REFERENCES xml_catalog
|
233 |
|
|
);
|
234 |
|
|
|
235 |
|
|
/*
|
236 |
|
|
* Index of <docid,doctype> in xml_document
|
237 |
|
|
*/
|
238 |
|
|
CREATE INDEX xml_documents_idx1 ON xml_documents (docid, doctype);
|
239 |
4415
|
daigle
|
CREATE INDEX xml_documents_idx2 ON xml_documents (lower(user_owner));
|
240 |
4104
|
daigle
|
CREATE INDEX xml_documents_idx3 ON xml_documents (rootnodeid);
|
241 |
|
|
|
242 |
|
|
/*
|
243 |
|
|
* Revised Documents -- table to store XML documents saved after an UPDATE
|
244 |
|
|
* or DELETE
|
245 |
|
|
*/
|
246 |
|
|
CREATE TABLE xml_revisions (
|
247 |
|
|
revisionid NUMBER(20), -- the revision number we are saving
|
248 |
|
|
docid VARCHAR2(250), -- the document id #
|
249 |
|
|
rootnodeid NUMBER(20), -- reference to root node of the DOM
|
250 |
|
|
docname VARCHAR2(100), -- usually the root element name
|
251 |
|
|
doctype VARCHAR2(100), -- public id indicating document type
|
252 |
|
|
user_owner VARCHAR2(100),
|
253 |
|
|
user_updated VARCHAR2(100),
|
254 |
|
|
server_location NUMBER(20),
|
255 |
|
|
rev NUMBER(10),
|
256 |
|
|
date_created DATE,
|
257 |
|
|
date_updated DATE,
|
258 |
|
|
public_access NUMBER(1), -- flag for public access
|
259 |
|
|
catalog_id NUMBER(20), -- reference to xml_catalog
|
260 |
|
|
CONSTRAINT xml_revisions_pk PRIMARY KEY (revisionid),
|
261 |
|
|
CONSTRAINT xml_revisions_rep_fk
|
262 |
|
|
FOREIGN KEY (server_location) REFERENCES xml_replication,
|
263 |
|
|
CONSTRAINT xml_revisions_root_fk
|
264 |
|
|
FOREIGN KEY (rootnodeid) REFERENCES xml_nodes_revisions,
|
265 |
|
|
CONSTRAINT xml_revisions_catalog_fk
|
266 |
|
|
FOREIGN KEY (catalog_id) REFERENCES xml_catalog
|
267 |
|
|
);
|
268 |
|
|
|
269 |
|
|
CREATE SEQUENCE xml_revisions_id_seq;
|
270 |
|
|
|
271 |
|
|
CREATE TRIGGER xml_revisions_before_insert
|
272 |
|
|
BEFORE INSERT ON xml_revisions FOR EACH ROW
|
273 |
|
|
BEGIN
|
274 |
|
|
SELECT xml_revisions_id_seq.nextval
|
275 |
|
|
INTO :new.revisionid
|
276 |
|
|
FROM dual;
|
277 |
|
|
END;
|
278 |
|
|
/
|
279 |
|
|
|
280 |
|
|
/*
|
281 |
|
|
* ACL -- table to store ACL for XML documents by principals
|
282 |
|
|
*/
|
283 |
|
|
CREATE TABLE xml_access (
|
284 |
6122
|
leinfelder
|
guid VARCHAR2(2000), -- the globally unique string identifier
|
285 |
4104
|
daigle
|
accessfileid VARCHAR2(250), -- the document id # for the access file
|
286 |
|
|
principal_name VARCHAR2(100), -- name of user, group, etc.
|
287 |
|
|
permission NUMBER(1), -- "read", "write", "all"
|
288 |
|
|
perm_type VARCHAR2(32), -- "allowed" or "denied"
|
289 |
|
|
perm_order VARCHAR2(32), -- "allow first" or "deny first"
|
290 |
|
|
begin_time DATE, -- the time that permission begins
|
291 |
|
|
end_time DATE, -- the time that permission ends
|
292 |
|
|
ticket_count NUMBER(5), -- ticket counter for that permission
|
293 |
|
|
subtreeid VARCHAR2(32), -- sub tree id
|
294 |
|
|
startnodeid NUMBER(20), -- start node for sub tree
|
295 |
|
|
endnodeid NUMBER(20), -- end node for sub tree
|
296 |
|
|
CONSTRAINT xml_access_ck CHECK (begin_time < end_time),
|
297 |
|
|
);
|
298 |
4415
|
daigle
|
CREATE INDEX xml_access_idx1 ON xml_access (lower(principal_name));
|
299 |
|
|
CREATE INDEX xml_access_idx2 ON xml_access (permission);
|
300 |
|
|
CREATE INDEX xml_access_idx3 ON xml_access (perm_type);
|
301 |
|
|
CREATE INDEX xml_access_idx4 ON xml_access (perm_order);
|
302 |
|
|
CREATE INDEX xml_access_idx5 ON xml_access (subtreeid);
|
303 |
4104
|
daigle
|
|
304 |
|
|
|
305 |
|
|
/*
|
306 |
|
|
* Index of Nodes -- table to store precomputed paths through tree for
|
307 |
|
|
* quick searching in structured searches
|
308 |
|
|
*/
|
309 |
|
|
CREATE TABLE xml_index (
|
310 |
|
|
nodeid NUMBER(20), -- the unique node id
|
311 |
|
|
path VARCHAR2(1000), -- precomputed path through tree
|
312 |
|
|
docid VARCHAR2(250), -- index to the document id
|
313 |
|
|
doctype VARCHAR2(100), -- public id indicating document type
|
314 |
|
|
parentnodeid NUMBER(20), -- id of the parent of the node
|
315 |
|
|
-- represented by this row
|
316 |
|
|
CONSTRAINT xml_index_pk PRIMARY KEY (nodeid,path),
|
317 |
|
|
CONSTRAINT xml_index_nodeid_fk FOREIGN KEY (nodeid) REFERENCES xml_nodes,
|
318 |
|
|
CONSTRAINT xml_index_docid_fk
|
319 |
|
|
FOREIGN KEY (docid) REFERENCES xml_documents
|
320 |
|
|
);
|
321 |
|
|
|
322 |
|
|
/*
|
323 |
|
|
* Index of the paths in xml_index
|
324 |
|
|
*/
|
325 |
|
|
CREATE INDEX xml_index_idx1 ON xml_index (path);
|
326 |
|
|
CREATE INDEX xml_index_idx2 ON xml_index (docid);
|
327 |
|
|
CREATE INDEX xml_index_idx3 ON xml_index (nodeid);
|
328 |
|
|
|
329 |
|
|
|
330 |
|
|
/*
|
331 |
|
|
* Index of Paths - table to store nodes with paths specified by userst in metacat.properties
|
332 |
|
|
*/
|
333 |
|
|
CREATE TABLE xml_path_index (
|
334 |
|
|
nodeid NUMBER(20), -- the unique node id
|
335 |
|
|
docid VARCHAR2(250), -- index to the document id
|
336 |
|
|
path VARCHAR2(1000), -- precomputed path through tree
|
337 |
|
|
nodedata VARCHAR2(4000), -- the data for this node e.g.,
|
338 |
|
|
nodedatanumerical NUMBER(20), -- the data for this node if
|
339 |
6012
|
leinfelder
|
nodedatadate TIMESTAMP, -- the data for this node if it is a date
|
340 |
|
|
parentnodeid NUMBER(20), -- index of the parent of this node
|
341 |
4104
|
daigle
|
CONSTRAINT xml_path_index_pk PRIMARY KEY (nodeid),
|
342 |
|
|
CONSTRAINT xml_path_index_docid_fk FOREIGN KEY (docid) REFERENCES xml_documents
|
343 |
|
|
);
|
344 |
|
|
|
345 |
|
|
|
346 |
|
|
/*
|
347 |
|
|
* create sequence an trigger
|
348 |
|
|
*/
|
349 |
|
|
CREATE SEQUENCE xml_path_index_id_seq;
|
350 |
|
|
CREATE TRIGGER xml_path_index_before_insert
|
351 |
|
|
BEFORE INSERT ON xml_path_index FOR EACH ROW
|
352 |
|
|
BEGIN
|
353 |
|
|
SELECT xml_path_index_id_seq.nextval
|
354 |
|
|
INTO :new.nodeid
|
355 |
|
|
FROM dual;
|
356 |
|
|
END;
|
357 |
|
|
/
|
358 |
|
|
|
359 |
|
|
|
360 |
|
|
/*
|
361 |
|
|
* Index of the path, nodedata, nodedatanumerical in xml_path_index
|
362 |
|
|
*/
|
363 |
|
|
CREATE INDEX xml_path_index_idx1 ON xml_path_index (path);
|
364 |
|
|
CREATE INDEX xml_path_index_idx2 ON xml_path_index (nodedata);
|
365 |
|
|
CREATE INDEX xml_path_index_idx3 ON xml_path_index (nodedatanumerical);
|
366 |
6012
|
leinfelder
|
CREATE INDEX xml_path_index_idx4 ON xml_path_index (nodedatadate);
|
367 |
4104
|
daigle
|
|
368 |
|
|
|
369 |
|
|
|
370 |
6012
|
leinfelder
|
|
371 |
4104
|
daigle
|
CREATE TABLE xml_relation (
|
372 |
|
|
relationid NUMBER(20) PRIMARY KEY, -- unique id
|
373 |
|
|
docid VARCHAR2(250), -- the docid of the package file
|
374 |
|
|
-- that this relation came from
|
375 |
|
|
packagetype VARCHAR2(250), -- the type of the package
|
376 |
|
|
subject VARCHAR2(512) NOT NULL, -- the subject of the relation
|
377 |
|
|
subdoctype VARCHAR2(128), -- the doctype of the subject
|
378 |
|
|
relationship VARCHAR2(128) NOT NULL,-- the relationship type
|
379 |
|
|
object VARCHAR2(512) NOT NULL, -- the object of the relation
|
380 |
|
|
objdoctype VARCHAR2(128), -- the doctype of the object
|
381 |
|
|
CONSTRAINT xml_relation_uk UNIQUE (docid, subject, relationship, object),
|
382 |
|
|
CONSTRAINT xml_relation_docid_fk
|
383 |
|
|
FOREIGN KEY (docid) REFERENCES xml_documents
|
384 |
|
|
);
|
385 |
|
|
|
386 |
|
|
CREATE SEQUENCE xml_relation_id_seq;
|
387 |
|
|
|
388 |
|
|
CREATE TRIGGER xml_relation_before_insert
|
389 |
|
|
BEFORE INSERT ON xml_relation FOR EACH ROW
|
390 |
|
|
BEGIN
|
391 |
|
|
SELECT xml_relation_id_seq.nextval
|
392 |
|
|
INTO :new.relationid
|
393 |
|
|
FROM dual;
|
394 |
|
|
END;
|
395 |
|
|
/
|
396 |
|
|
|
397 |
|
|
/*
|
398 |
5371
|
berkley
|
* Table used to store all document identifiers for system metadata objects
|
399 |
|
|
* similar restraints to identifier. Cannot use identifier table for this
|
400 |
|
|
* purpose because then you have to worry about whether you insert the
|
401 |
|
|
* data first or the systemMetadata first.
|
402 |
|
|
*/
|
403 |
|
|
CREATE TABLE systemMetadata (
|
404 |
|
|
guid VARCHAR2(2000), -- the globally unique string identifier
|
405 |
6561
|
leinfelder
|
serial_version VARCHAR2(256), --the serial version of the object
|
406 |
5887
|
berkley
|
date_uploaded DATE, -- the date/time the document was first submitted
|
407 |
|
|
rights_holder VARCHAR2(250), --the user who has rights to the document, usually the first persons to upload it
|
408 |
|
|
checksum VARCHAR2(512), --the checksum of the doc using the given algorithm (see below)
|
409 |
|
|
checksum_algorithm VARCHAR2(250), --the algorithm used to calculate the checksum
|
410 |
|
|
origin_member_node VARCHAR2(250), --the member node where the document was first uploaded
|
411 |
|
|
authoritive_member_node VARCHAR2(250), --the member node that currently controls the document
|
412 |
|
|
date_modified DATE, -- the last date/time that the file was changed
|
413 |
5917
|
berkley
|
submitter VARCHAR2(256), -- the user who originally submitted the doc
|
414 |
|
|
object_format VARCHAR2(256), --the format of the object
|
415 |
6098
|
leinfelder
|
size VARCHAR2(256), --the size of the object
|
416 |
6766
|
leinfelder
|
archived boolean, -- specifies whether this an archived object
|
417 |
6107
|
leinfelder
|
replication_allowed boolean, -- replication allowed
|
418 |
|
|
number_replicas NUMBER(8), -- the number of replicas allowed
|
419 |
6375
|
leinfelder
|
obsoletes VARCHAR2(2000), -- the identifier of the record that this replaces
|
420 |
|
|
obsoleted_by VARCHAR2(2000), -- the identifier of the record that replaces this record
|
421 |
6098
|
leinfelder
|
CONSTRAINT systemMetadata_pk
|
422 |
|
|
PRIMARY KEY (guid)
|
423 |
5371
|
berkley
|
)
|
424 |
|
|
|
425 |
6107
|
leinfelder
|
CREATE TABLE systemMetadataReplicationPolicy (
|
426 |
|
|
guid VARCHAR2(2000), -- the globally unique string identifier of the object that the system metadata describes
|
427 |
|
|
member_node VARCHAR(250), -- replication member node
|
428 |
|
|
policy VARCHAR2(2000), -- the policy (preferred, blocked, etc...TBD)
|
429 |
|
|
CONSTRAINT systemMetadataReplicationPolicy_fk
|
430 |
|
|
FOREIGN KEY (guid) REFERENCES systemMetadata
|
431 |
|
|
);
|
432 |
|
|
|
433 |
|
|
CREATE TABLE systemMetadataReplicationStatus (
|
434 |
|
|
guid VARCHAR2(2000), -- the globally unique string identifier of the object that the system metadata describes
|
435 |
|
|
member_node VARCHAR(250), -- replication member node
|
436 |
|
|
status VARCHAR(250), -- replication status
|
437 |
|
|
date_verified DATE, -- the date replication was verified
|
438 |
|
|
CONSTRAINT systemMetadataReplicationStatus_fk
|
439 |
|
|
FOREIGN KEY (guid) REFERENCES systemMetadata
|
440 |
|
|
);
|
441 |
|
|
|
442 |
6098
|
leinfelder
|
/*
|
443 |
4104
|
daigle
|
* Table used to store all document identifiers in metacat. Each identifier
|
444 |
5276
|
jones
|
* has a globally unique, unconstrained string, which we will refer to as a
|
445 |
|
|
* GUID, and a local metacat identifier, which consists of the docid
|
446 |
|
|
* and revision fields. Each row maps one global identifier to the local
|
447 |
|
|
* identifier (docid) used within metacat.
|
448 |
4104
|
daigle
|
*/
|
449 |
|
|
CREATE TABLE identifier (
|
450 |
5276
|
jones
|
guid VARCHAR2(2000), -- the globally unique string identifier
|
451 |
|
|
docid VARCHAR2(250), -- the local document id #
|
452 |
|
|
rev NUMBER(8) -- the revision part of the local identifier
|
453 |
4104
|
daigle
|
);
|
454 |
|
|
|
455 |
|
|
/*
|
456 |
|
|
* accesssubtree -- table to store access subtree info
|
457 |
|
|
*/
|
458 |
|
|
CREATE TABLE xml_accesssubtree (
|
459 |
|
|
docid VARCHAR2(250), -- the document id #
|
460 |
|
|
rev NUMBER(10) DEFAULT 1, --the revision number of the docume
|
461 |
|
|
controllevel VARCHAR2(50), -- the level it control -- document or subtree
|
462 |
|
|
subtreeid VARCHAR2(250), -- the subtree id
|
463 |
|
|
startnodeid NUMBER(20), -- the start node id of access subtree
|
464 |
|
|
endnodeid NUMBER(20), -- the end node if of access subtree
|
465 |
|
|
CONSTRAINT xml_accesssubtree_docid_fk
|
466 |
|
|
FOREIGN KEY (docid) REFERENCES xml_documents
|
467 |
|
|
);
|
468 |
|
|
|
469 |
|
|
/*
|
470 |
|
|
* Returnfields -- table to store combinations of returnfields requested
|
471 |
|
|
* and the number of times this table is accessed
|
472 |
|
|
*/
|
473 |
|
|
CREATE TABLE xml_returnfield (
|
474 |
|
|
returnfield_id NUMBER(20), -- the id for this returnfield entry
|
475 |
|
|
returnfield_string VARCHAR2(2000), -- the returnfield string
|
476 |
|
|
usage_count NUMBER(20), -- the number of times this string
|
477 |
|
|
-- has been requested
|
478 |
|
|
CONSTRAINT xml_returnfield_pk PRIMARY KEY (returnfield_id)
|
479 |
|
|
);
|
480 |
|
|
CREATE INDEX xml_returnfield_idx1 ON xml_returnfield(returnfield_string);
|
481 |
|
|
|
482 |
|
|
CREATE SEQUENCE xml_returnfield_id_seq;
|
483 |
|
|
|
484 |
|
|
CREATE TRIGGER xml_returnfield_before_insert
|
485 |
|
|
BEFORE INSERT ON xml_returnfield FOR EACH ROW
|
486 |
|
|
BEGIN
|
487 |
|
|
SELECT xml_returnfield_id_seq.nextval
|
488 |
|
|
INTO :new.returnfield_id
|
489 |
|
|
FROM dual;
|
490 |
|
|
END;
|
491 |
|
|
/
|
492 |
|
|
|
493 |
|
|
/*
|
494 |
|
|
* Queryresults -- table to store queryresults for a given docid
|
495 |
|
|
* and returnfield_id
|
496 |
|
|
*/
|
497 |
|
|
CREATE TABLE xml_queryresult(
|
498 |
|
|
queryresult_id NUMBER(20), -- id for this entry
|
499 |
|
|
returnfield_id NUMBER(20), -- id for the returnfield corresponding to this entry
|
500 |
|
|
docid VARCHAR2(250), -- docid of the document
|
501 |
|
|
queryresult_string VARCHAR2(4000), -- resultant text generated for this docid and given
|
502 |
|
|
-- returnfield
|
503 |
|
|
CONSTRAINT xml_queryresult_pk PRIMARY KEY (queryresult_id),
|
504 |
|
|
CONSTRAINT xml_queryresult_searchid_fk
|
505 |
|
|
FOREIGN KEY (returnfield_id) REFERENCES xml_returnfield
|
506 |
|
|
);
|
507 |
|
|
|
508 |
|
|
CREATE INDEX xml_queryresult_idx1 ON xml_queryresult (returnfield_id, docid);
|
509 |
|
|
|
510 |
|
|
CREATE SEQUENCE xml_queryresult_id_seq;
|
511 |
|
|
|
512 |
|
|
CREATE TRIGGER xml_queryresult_before_insert
|
513 |
|
|
BEFORE INSERT ON xml_queryresult FOR EACH ROW
|
514 |
|
|
BEGIN
|
515 |
|
|
SELECT xml_queryresult_id_seq.nextval
|
516 |
|
|
INTO :new.queryresult_id
|
517 |
|
|
FROM dual;
|
518 |
|
|
END;
|
519 |
|
|
/
|
520 |
|
|
|
521 |
|
|
|
522 |
|
|
|
523 |
|
|
|
524 |
|
|
/*
|
525 |
|
|
* Logging -- table to store metadata and data access log
|
526 |
|
|
*/
|
527 |
|
|
CREATE TABLE access_log (
|
528 |
|
|
entryid NUMBER(20), -- the identifier for the log event
|
529 |
|
|
ip_address VARCHAR2(512), -- the ip address inititiating the event
|
530 |
6542
|
leinfelder
|
user_agent VARCHAR2(512), -- the user agent for the request
|
531 |
4104
|
daigle
|
principal VARCHAR2(512), -- the user initiiating the event
|
532 |
|
|
docid VARCHAR2(250), -- the document id #
|
533 |
|
|
event VARCHAR2(512), -- the code symbolizing the event type
|
534 |
|
|
date_logged DATE, -- the datetime on which the event occurred
|
535 |
|
|
CONSTRAINT access_log_pk PRIMARY KEY (entryid)
|
536 |
|
|
);
|
537 |
|
|
|
538 |
|
|
CREATE SEQUENCE access_log_id_seq;
|
539 |
|
|
CREATE TRIGGER access_log_before_insert
|
540 |
|
|
BEFORE INSERT ON access_log FOR EACH ROW
|
541 |
|
|
BEGIN
|
542 |
|
|
SELECT access_log_id_seq.nextval
|
543 |
|
|
INTO :new.entryid
|
544 |
|
|
FROM dual;
|
545 |
|
|
END;
|
546 |
|
|
/
|
547 |
|
|
|
548 |
|
|
/*
|
549 |
|
|
* harvest_site_schedule -- table to store harvest sites and schedule info
|
550 |
|
|
*/
|
551 |
|
|
CREATE TABLE harvest_site_schedule (
|
552 |
|
|
site_schedule_id NUMBER, -- unique id
|
553 |
|
|
documentlisturl VARCHAR2(255), -- URL of the site harvest document list
|
554 |
|
|
ldapdn VARCHAR2(255), -- LDAP distinguished name for site account
|
555 |
|
|
datenextharvest DATE, -- scheduled date of next harvest
|
556 |
|
|
datelastharvest DATE, -- recorded date of last harvest
|
557 |
|
|
updatefrequency NUMBER, -- the harvest update frequency
|
558 |
|
|
unit VARCHAR2(50), -- update unit -- days weeks or months
|
559 |
|
|
contact_email VARCHAR2(50), -- email address of the site contact person
|
560 |
|
|
ldappwd VARCHAR2(20), -- LDAP password for site account
|
561 |
|
|
CONSTRAINT harvest_site_schedule_pk PRIMARY KEY (site_schedule_id)
|
562 |
|
|
);
|
563 |
|
|
|
564 |
|
|
/*
|
565 |
|
|
* harvest_log -- table to log entries for harvest operations
|
566 |
|
|
*/
|
567 |
|
|
CREATE TABLE harvest_log (
|
568 |
|
|
harvest_log_id NUMBER, -- unique id
|
569 |
|
|
harvest_date DATE, -- date of the current harvest
|
570 |
|
|
status NUMBER, -- non-zero indicates an error status
|
571 |
|
|
message VARCHAR2(1000), -- text message for this log entry
|
572 |
|
|
harvest_operation_code VARCHAR2(30), -- the type of harvest operation
|
573 |
|
|
site_schedule_id NUMBER, -- site schedule id, or 0 if no site
|
574 |
|
|
CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id)
|
575 |
|
|
);
|
576 |
|
|
|
577 |
|
|
/*
|
578 |
|
|
* harvest_detail_log -- table to log detailed info about documents that
|
579 |
|
|
* generated errors during the harvest
|
580 |
|
|
*/
|
581 |
|
|
CREATE TABLE harvest_detail_log (
|
582 |
|
|
detail_log_id NUMBER, -- unique id
|
583 |
|
|
harvest_log_id NUMBER, -- ponter to the related log entry
|
584 |
|
|
scope VARCHAR2(50), -- document scope
|
585 |
|
|
identifier NUMBER, -- document identifier
|
586 |
|
|
revision NUMBER, -- document revision
|
587 |
|
|
document_url VARCHAR2(255), -- document URL
|
588 |
|
|
error_message VARCHAR2(1000), -- text error message
|
589 |
|
|
document_type VARCHAR2(100), -- document type
|
590 |
|
|
CONSTRAINT harvest_detail_log_pk PRIMARY KEY (detail_log_id),
|
591 |
|
|
CONSTRAINT harvest_detail_log_fk
|
592 |
|
|
FOREIGN KEY (harvest_log_id) REFERENCES harvest_log
|
593 |
|
|
);
|
594 |
|
|
|
595 |
|
|
/*
|
596 |
|
|
* db_version -- table to store the version history of this database
|
597 |
|
|
*/
|
598 |
|
|
CREATE TABLE db_version (
|
599 |
|
|
db_version_id NUMBER(20), -- the identifier for the version
|
600 |
|
|
version VARCHAR(250), -- the version number
|
601 |
|
|
status NUMBER(20), -- status of the version
|
602 |
|
|
date_created DATE, -- the datetime on which the version was created
|
603 |
|
|
CONSTRAINT db_version_pk PRIMARY KEY (db_version_id)
|
604 |
|
|
);
|
605 |
|
|
|
606 |
|
|
CREATE SEQUENCE db_version_id_seq;
|
607 |
|
|
CREATE TRIGGER db_version_before_insert
|
608 |
|
|
BEFORE INSERT ON db_version FOR EACH ROW
|
609 |
|
|
BEGIN
|
610 |
|
|
SELECT db_version_id_seq.nextval
|
611 |
|
|
INTO :new.db_version_id
|
612 |
|
|
FROM dual;
|
613 |
|
|
END;
|
614 |
|
|
/
|
615 |
|
|
|
616 |
4975
|
daigle
|
/*
|
617 |
|
|
* scheduled_job -- table to store scheduled jobs
|
618 |
|
|
*/
|
619 |
|
|
CREATE TABLE scheduled_job (
|
620 |
|
|
id NUMBER(20) NOT NULL default nextval('scheduled_job_id_seq'),
|
621 |
|
|
date_created TIMESTAMP NOT NULL,
|
622 |
|
|
date_updated TIMESTAMP NOT NULL,
|
623 |
|
|
status VARCHAR2(64) NOT NULL,
|
624 |
|
|
name VARCHAR2(512) NOT NULL,
|
625 |
|
|
trigger_name VARCHAR2(512) NOT NULL,
|
626 |
|
|
group_name VARCHAR2(512) NOT NULL,
|
627 |
|
|
class_name VARCHAR2(1024) NOT NULL,
|
628 |
|
|
start_time TIMESTAMP NOT NULL,
|
629 |
|
|
interval_value NUMBER NOT NULL,
|
630 |
|
|
interval_unit VARCHAR2(8) NOT NULL,
|
631 |
|
|
CONSTRAINT scheduled_job_pk PRIMARY KEY (id),
|
632 |
|
|
CONSTRAINT scheduled_job_uk UNIQUE (name)
|
633 |
|
|
);
|
634 |
|
|
|
635 |
|
|
CREATE SEQUENCE scheduled_job_id_seq;
|
636 |
|
|
CREATE TRIGGER scheduled_job_before_insert
|
637 |
|
|
BEFORE INSERT ON scheduled_job FOR EACH ROW
|
638 |
|
|
BEGIN
|
639 |
|
|
SELECT scheduled_job_id_seq.nextval
|
640 |
|
|
INTO :new.id
|
641 |
|
|
FROM dual;
|
642 |
|
|
END;
|
643 |
|
|
/
|
644 |
|
|
|
645 |
|
|
/*
|
646 |
|
|
* scheduled_job_params -- table to store scheduled job parameters
|
647 |
|
|
*/
|
648 |
|
|
CREATE TABLE scheduled_job_params (
|
649 |
|
|
id NUMBER(20) NOT NULL default nextval('scheduled_job_params_id_seq'),
|
650 |
|
|
date_created TIMESTAMP NOT NULL,
|
651 |
|
|
date_updated TIMESTAMP NOT NULL,
|
652 |
|
|
status VARCHAR2(64) NOT NULL,
|
653 |
|
|
job_id NUMBER(20) NOT NULL,
|
654 |
|
|
key VARCHAR2(64) NOT NULL,
|
655 |
|
|
value VARCHAR2(1024) NOT NULL,
|
656 |
|
|
CONSTRAINT scheduled_job_params_pk PRIMARY KEY (id),
|
657 |
|
|
CONSTRAINT scheduled_job_params_fk
|
658 |
|
|
FOREIGN KEY (job_id) REFERENCES scheduled_job(id)
|
659 |
|
|
);
|
660 |
|
|
|
661 |
|
|
CREATE SEQUENCE scheduled_job_params_id_seq;
|
662 |
|
|
CREATE TRIGGER scheduled_job_params_before_insert
|
663 |
|
|
BEFORE INSERT ON scheduled_job_params FOR EACH ROW
|
664 |
|
|
BEGIN
|
665 |
|
|
SELECT scheduled_job_id_params_seq.nextval
|
666 |
|
|
INTO :new.id
|
667 |
|
|
FROM dual;
|
668 |
|
|
END;
|
669 |
|
|
/
|