1
|
/**
|
2
|
* '$RCSfile$'
|
3
|
* Copyright: 2004 Regents of the University of California and the
|
4
|
* National Center for Ecological Analysis and Synthesis
|
5
|
*
|
6
|
* '$Author: tao $'
|
7
|
* '$Date: 2007-09-10 18:23:10 -0700 (Mon, 10 Sep 2007) $'
|
8
|
* '$Revision: 3413 $'
|
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 identifier_id_seq;
|
36
|
DROP SEQUENCE access_log_id_seq;
|
37
|
DROP SEQUENCE xml_returnfield_id_seq;
|
38
|
DROP SEQUENCE xml_queryresult_id_seq;
|
39
|
DROP SEQUENCE xml_path_index_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 identifier_before_insert;
|
48
|
DROP TRIGGER access_log_before_insert;
|
49
|
DROP TRIGGER xml_returnfield_before_insert;
|
50
|
DROP TRIGGER xml_queryresult_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
|
DROP TABLE access_log;
|
65
|
DROP TABLE harvest_site_schedule;
|
66
|
DROP TABLE harvest_detail_log;
|
67
|
DROP TABLE harvest_log;
|
68
|
DROP TABLE xml_queryresult;
|
69
|
DROP TABLE xml_returnfield;
|
70
|
DROP TABLE xml_path_index;
|
71
|
|
72
|
/*
|
73
|
*Replication -- table to store servers that metacat is replicated to
|
74
|
*/
|
75
|
CREATE TABLE xml_replication (
|
76
|
serverid NUMBER(20),
|
77
|
server VARCHAR2(512),
|
78
|
last_checked DATE,
|
79
|
replicate NUMBER(1),
|
80
|
datareplicate NUMBER(1),
|
81
|
hub NUMBER(1),
|
82
|
CONSTRAINT xml_replication_pk PRIMARY KEY (serverid)
|
83
|
);
|
84
|
|
85
|
CREATE SEQUENCE xml_replication_id_seq;
|
86
|
CREATE TRIGGER xml_replication_before_insert
|
87
|
BEFORE INSERT ON xml_replication FOR EACH ROW
|
88
|
BEGIN
|
89
|
SELECT xml_replication_id_seq.nextval
|
90
|
INTO :new.serverid
|
91
|
FROM dual;
|
92
|
END;
|
93
|
/
|
94
|
|
95
|
INSERT INTO xml_replication (server, replicate, datareplicate, hub)
|
96
|
VALUES ('localhost', '0', '0', '0');
|
97
|
|
98
|
/*
|
99
|
* Nodes -- table to store XML Nodes (both elements and attributes)
|
100
|
*/
|
101
|
CREATE SEQUENCE xml_nodes_id_seq;
|
102
|
CREATE TABLE xml_nodes (
|
103
|
nodeid NUMBER(20), -- the unique node id (pk)
|
104
|
nodeindex NUMBER(10), -- order of nodes within parent
|
105
|
nodetype VARCHAR2(20), -- type (DOCUMENT, COMMENT, PI,
|
106
|
-- ELEMENT, ATTRIBUTE, TEXT)
|
107
|
nodename VARCHAR2(250), -- the name of an element or attribute
|
108
|
nodeprefix VARCHAR2(50), -- the namespace prefix of an element
|
109
|
-- or attribute
|
110
|
nodedata VARCHAR2(4000), -- the data for this node (e.g.,
|
111
|
-- for TEXT it is the content)
|
112
|
parentnodeid NUMBER(20), -- index of the parent of this node
|
113
|
rootnodeid NUMBER(20), -- index of the root node of this tree
|
114
|
docid VARCHAR2(250), -- index to the document id
|
115
|
date_created DATE,
|
116
|
date_updated DATE,
|
117
|
nodedatanumerical NUMBER, -- the data for this node if
|
118
|
-- it is a number
|
119
|
CONSTRAINT xml_nodes_pk PRIMARY KEY (nodeid),
|
120
|
CONSTRAINT xml_nodes_root_fk
|
121
|
FOREIGN KEY (rootnodeid) REFERENCES xml_nodes,
|
122
|
CONSTRAINT xml_nodes_parent_fk
|
123
|
FOREIGN KEY (parentnodeid) REFERENCES xml_nodes
|
124
|
);
|
125
|
CREATE TRIGGER xml_nodes_before_insert
|
126
|
BEFORE INSERT ON xml_nodes FOR EACH ROW
|
127
|
BEGIN
|
128
|
SELECT xml_nodes_id_seq.nextval
|
129
|
INTO :new.nodeid
|
130
|
FROM dual;
|
131
|
END;
|
132
|
/
|
133
|
|
134
|
|
135
|
/*
|
136
|
* Indexes of rootnodeid, parentnodeid, and nodename in xml_nodes
|
137
|
*/
|
138
|
CREATE INDEX xml_nodes_idx1 ON xml_nodes (rootnodeid);
|
139
|
CREATE INDEX xml_nodes_idx2 ON xml_nodes (parentnodeid);
|
140
|
CREATE INDEX xml_nodes_idx3 ON xml_nodes (nodename);
|
141
|
CREATE INDEX xml_nodes_idx4 ON xml_nodes (docid);
|
142
|
|
143
|
|
144
|
/*
|
145
|
* xml_nodes_revisions -- table to store nodes from xml_nodes which are of old revisions and deleted document
|
146
|
*/
|
147
|
|
148
|
CREATE TABLE xml_nodes_revisions (
|
149
|
nodeid NUMBER(20), -- the unique node id (pk)
|
150
|
nodeindex NUMBER(10), -- order of nodes within parent
|
151
|
nodetype VARCHAR2(20), -- type (DOCUMENT, COMMENT, PI,
|
152
|
-- ELEMENT, ATTRIBUTE, TEXT)
|
153
|
nodename VARCHAR2(250), -- the name of an element or attribute
|
154
|
nodeprefix VARCHAR2(50), -- the namespace prefix of an element
|
155
|
-- or attribute
|
156
|
nodedata VARCHAR2(4000), -- the data for this node (e.g.,
|
157
|
-- for TEXT it is the content)
|
158
|
parentnodeid NUMBER(20), -- index of the parent of this node
|
159
|
rootnodeid NUMBER(20), -- index of the root node of this tree
|
160
|
docid VARCHAR2(250), -- index to the document id
|
161
|
date_created DATE,
|
162
|
date_updated DATE,
|
163
|
nodedatanumerical NUMBER, -- the data for this node if
|
164
|
-- it is a number
|
165
|
CONSTRAINT xml_nodes_revisions_pk PRIMARY KEY (nodeid),
|
166
|
CONSTRAINT xml_nodes_revisions_root_fk
|
167
|
FOREIGN KEY (rootnodeid) REFERENCES xml_nodes_revisions,
|
168
|
CONSTRAINT xml_nodes_revisions_parent_fk
|
169
|
FOREIGN KEY (parentnodeid) REFERENCES xml_nodes_revisions
|
170
|
);
|
171
|
|
172
|
|
173
|
/*
|
174
|
* Indexes of rootnodeid, parentnodeid, and nodename in xml_nodes_revision
|
175
|
*/
|
176
|
CREATE INDEX xml_nodes_revisions_idx1 ON xml_nodes_revisions (rootnodeid);
|
177
|
CREATE INDEX xml_nodes_revisions_idx2 ON xml_nodes_revisions (parentnodeid);
|
178
|
CREATE INDEX xml_nodes_revisions_idx3 ON xml_nodes_revisions (nodename);
|
179
|
|
180
|
/*
|
181
|
* XML Catalog -- table to store all external sources for XML documents
|
182
|
*/
|
183
|
CREATE TABLE xml_catalog (
|
184
|
catalog_id NUMBER(20), -- the id for this catalog entry
|
185
|
entry_type VARCHAR2(500), -- the type of this catalog entry
|
186
|
-- (e.g., DTD, XSD, XSL)
|
187
|
source_doctype VARCHAR2(500), -- the source public_id for transforms
|
188
|
target_doctype VARCHAR2(500), -- the target public_id for transforms
|
189
|
public_id VARCHAR2(500), -- the unique id for this type
|
190
|
system_id VARCHAR2(1000), -- the local location of the object
|
191
|
CONSTRAINT xml_catalog_pk PRIMARY KEY (catalog_id),
|
192
|
CONSTRAINT xml_catalog_uk UNIQUE
|
193
|
(entry_type, source_doctype, target_doctype, public_id)
|
194
|
);
|
195
|
|
196
|
CREATE SEQUENCE xml_catalog_id_seq;
|
197
|
|
198
|
CREATE TRIGGER xml_catalog_before_insert
|
199
|
BEFORE INSERT ON xml_catalog FOR EACH ROW
|
200
|
BEGIN
|
201
|
SELECT xml_catalog_id_seq.nextval
|
202
|
INTO :new.catalog_id
|
203
|
FROM dual;
|
204
|
END;
|
205
|
/
|
206
|
|
207
|
/*
|
208
|
* Documents -- table to store XML documents
|
209
|
*/
|
210
|
CREATE TABLE xml_documents (
|
211
|
docid VARCHAR2(250), -- the document id #
|
212
|
rootnodeid NUMBER(20), -- reference to root node of the DOM
|
213
|
docname VARCHAR2(100), -- usually the root element name
|
214
|
doctype VARCHAR2(100), -- public id indicating document type
|
215
|
user_owner VARCHAR2(100), -- the user owned the document
|
216
|
user_updated VARCHAR2(100), -- the user updated the document
|
217
|
server_location NUMBER(20), -- the server on which this document
|
218
|
-- originates
|
219
|
rev NUMBER(10) DEFAULT 1,--the revision number of the docume
|
220
|
date_created DATE,
|
221
|
date_updated DATE,
|
222
|
public_access NUMBER(1), -- flag for public access
|
223
|
catalog_id NUMBER(20), -- reference to xml_catalog
|
224
|
CONSTRAINT xml_documents_pk PRIMARY KEY (docid),
|
225
|
CONSTRAINT xml_documents_rep_fk
|
226
|
FOREIGN KEY (server_location) REFERENCES xml_replication,
|
227
|
CONSTRAINT xml_documents_root_fk
|
228
|
FOREIGN KEY (rootnodeid) REFERENCES xml_nodes,
|
229
|
CONSTRAINT xml_documents_catalog_fk
|
230
|
FOREIGN KEY (catalog_id) REFERENCES xml_catalog
|
231
|
);
|
232
|
|
233
|
/*
|
234
|
* Index of <docid,doctype> in xml_document
|
235
|
*/
|
236
|
CREATE INDEX xml_documents_idx1 ON xml_documents (docid, doctype);
|
237
|
|
238
|
/*
|
239
|
* Revised Documents -- table to store XML documents saved after an UPDATE
|
240
|
* or DELETE
|
241
|
*/
|
242
|
CREATE TABLE xml_revisions (
|
243
|
revisionid NUMBER(20), -- the revision number we are saving
|
244
|
docid VARCHAR2(250), -- the document id #
|
245
|
rootnodeid NUMBER(20), -- reference to root node of the DOM
|
246
|
docname VARCHAR2(100), -- usually the root element name
|
247
|
doctype VARCHAR2(100), -- public id indicating document type
|
248
|
user_owner VARCHAR2(100),
|
249
|
user_updated VARCHAR2(100),
|
250
|
server_location NUMBER(20),
|
251
|
rev NUMBER(10),
|
252
|
date_created DATE,
|
253
|
date_updated DATE,
|
254
|
public_access NUMBER(1), -- flag for public access
|
255
|
catalog_id NUMBER(20), -- reference to xml_catalog
|
256
|
CONSTRAINT xml_revisions_pk PRIMARY KEY (revisionid),
|
257
|
CONSTRAINT xml_revisions_rep_fk
|
258
|
FOREIGN KEY (server_location) REFERENCES xml_replication,
|
259
|
CONSTRAINT xml_revisions_root_fk
|
260
|
FOREIGN KEY (rootnodeid) REFERENCES xml_nodes_revisions,
|
261
|
CONSTRAINT xml_revisions_catalog_fk
|
262
|
FOREIGN KEY (catalog_id) REFERENCES xml_catalog
|
263
|
);
|
264
|
|
265
|
CREATE SEQUENCE xml_revisions_id_seq;
|
266
|
|
267
|
CREATE TRIGGER xml_revisions_before_insert
|
268
|
BEFORE INSERT ON xml_revisions FOR EACH ROW
|
269
|
BEGIN
|
270
|
SELECT xml_revisions_id_seq.nextval
|
271
|
INTO :new.revisionid
|
272
|
FROM dual;
|
273
|
END;
|
274
|
/
|
275
|
|
276
|
/*
|
277
|
* ACL -- table to store ACL for XML documents by principals
|
278
|
*/
|
279
|
CREATE TABLE xml_access (
|
280
|
docid VARCHAR2(250), -- the document id #
|
281
|
accessfileid VARCHAR2(250), -- the document id # for the access file
|
282
|
principal_name VARCHAR2(100), -- name of user, group, etc.
|
283
|
permission NUMBER(1), -- "read", "write", "all"
|
284
|
perm_type VARCHAR2(32), -- "allowed" or "denied"
|
285
|
perm_order VARCHAR2(32), -- "allow first" or "deny first"
|
286
|
begin_time DATE, -- the time that permission begins
|
287
|
end_time DATE, -- the time that permission ends
|
288
|
ticket_count NUMBER(5), -- ticket counter for that permission
|
289
|
subtreeid VARCHAR2(32), -- sub tree id
|
290
|
startnodeid NUMBER(20), -- start node for sub tree
|
291
|
endnodeid NUMBER(20), -- end node for sub tree
|
292
|
CONSTRAINT xml_access_ck CHECK (begin_time < end_time),
|
293
|
CONSTRAINT xml_access_accessfileid_fk
|
294
|
FOREIGN KEY (accessfileid) REFERENCES xml_documents
|
295
|
);
|
296
|
|
297
|
|
298
|
|
299
|
/*
|
300
|
* Index of Nodes -- table to store precomputed paths through tree for
|
301
|
* quick searching in structured searches
|
302
|
*/
|
303
|
CREATE TABLE xml_index (
|
304
|
nodeid NUMBER(20), -- the unique node id
|
305
|
path VARCHAR2(1000), -- precomputed path through tree
|
306
|
docid VARCHAR2(250), -- index to the document id
|
307
|
doctype VARCHAR2(100), -- public id indicating document type
|
308
|
parentnodeid NUMBER(20), -- id of the parent of the node
|
309
|
-- represented by this row
|
310
|
CONSTRAINT xml_index_pk PRIMARY KEY (nodeid,path),
|
311
|
CONSTRAINT xml_index_nodeid_fk FOREIGN KEY (nodeid) REFERENCES xml_nodes,
|
312
|
CONSTRAINT xml_index_docid_fk
|
313
|
FOREIGN KEY (docid) REFERENCES xml_documents
|
314
|
);
|
315
|
|
316
|
/*
|
317
|
* Index of the paths in xml_index
|
318
|
*/
|
319
|
CREATE INDEX xml_index_idx1 ON xml_index (path);
|
320
|
CREATE INDEX xml_index_idx2 ON xml_index (docid);
|
321
|
|
322
|
|
323
|
/*
|
324
|
* Index of Paths - table to store nodes with paths specified by userst in metacat.properties
|
325
|
*/
|
326
|
CREATE TABLE xml_path_index (
|
327
|
nodeid NUMBER(20), -- the unique node id
|
328
|
docid VARCHAR2(250), -- index to the document id
|
329
|
path VARCHAR2(1000), -- precomputed path through tree
|
330
|
nodedata VARCHAR2(4000), -- the data for this node e.g.,
|
331
|
nodedatanumerical NUMBER(20), -- the data for this node if
|
332
|
parentnodeid NUMBER(20), -- index of the parent of this node
|
333
|
CONSTRAINT xml_path_index_pk PRIMARY KEY (nodeid),
|
334
|
CONSTRAINT xml_path_index_docid_fk FOREIGN KEY (docid) REFERENCES xml_documents
|
335
|
);
|
336
|
|
337
|
|
338
|
/*
|
339
|
* create sequence an trigger
|
340
|
*/
|
341
|
CREATE SEQUENCE xml_path_index_id_seq;
|
342
|
CREATE TRIGGER xml_path_index_before_insert
|
343
|
BEFORE INSERT ON xml_path_index FOR EACH ROW
|
344
|
BEGIN
|
345
|
SELECT xml_path_index_id_seq.nextval
|
346
|
INTO :new.nodeid
|
347
|
FROM dual;
|
348
|
END;
|
349
|
/
|
350
|
|
351
|
|
352
|
/*
|
353
|
* Index of the path, nodedata, nodedatanumerical in xml_path_index
|
354
|
*/
|
355
|
CREATE INDEX xml_path_index_idx1 ON xml_path_index (path);
|
356
|
CREATE INDEX xml_path_index_idx2 ON xml_path_index (nodedata);
|
357
|
CREATE INDEX xml_path_index_idx3 ON xml_path_index (nodedatanumerical);
|
358
|
|
359
|
|
360
|
|
361
|
CREATE TABLE xml_relation (
|
362
|
relationid NUMBER(20) PRIMARY KEY, -- unique id
|
363
|
docid VARCHAR2(250), -- the docid of the package file
|
364
|
-- that this relation came from
|
365
|
packagetype VARCHAR2(250), -- the type of the package
|
366
|
subject VARCHAR2(512) NOT NULL, -- the subject of the relation
|
367
|
subdoctype VARCHAR2(128), -- the doctype of the subject
|
368
|
relationship VARCHAR2(128) NOT NULL,-- the relationship type
|
369
|
object VARCHAR2(512) NOT NULL, -- the object of the relation
|
370
|
objdoctype VARCHAR2(128), -- the doctype of the object
|
371
|
CONSTRAINT xml_relation_uk UNIQUE (docid, subject, relationship, object),
|
372
|
CONSTRAINT xml_relation_docid_fk
|
373
|
FOREIGN KEY (docid) REFERENCES xml_documents
|
374
|
);
|
375
|
|
376
|
CREATE SEQUENCE xml_relation_id_seq;
|
377
|
|
378
|
CREATE TRIGGER xml_relation_before_insert
|
379
|
BEFORE INSERT ON xml_relation FOR EACH ROW
|
380
|
BEGIN
|
381
|
SELECT xml_relation_id_seq.nextval
|
382
|
INTO :new.relationid
|
383
|
FROM dual;
|
384
|
END;
|
385
|
/
|
386
|
|
387
|
/*
|
388
|
* Table used to store all document identifiers in metacat. Each identifier
|
389
|
* consists of 4 subparts, an authority, namespace, object, and revision as
|
390
|
* defined in the LSID specification.
|
391
|
*/
|
392
|
CREATE SEQUENCE identifier_id_seq;
|
393
|
CREATE TABLE identifier (
|
394
|
id NUMBER(20) PRIMARY KEY, -- primary key
|
395
|
authority VARCHAR2(255), -- the authority issuing the identifier
|
396
|
namespace VARCHAR2(255), -- the namespace qualifying the identifier
|
397
|
object VARCHAR2(255), -- the local part of the identifier for a particular object
|
398
|
revision VARCHAR2(255) -- the revision part of the identifier
|
399
|
);
|
400
|
CREATE TRIGGER identifier_before_insert
|
401
|
BEFORE INSERT ON identifier FOR EACH ROW
|
402
|
BEGIN
|
403
|
SELECT identifier_id_seq.nextval
|
404
|
INTO :new.id
|
405
|
FROM dual;
|
406
|
END;
|
407
|
/
|
408
|
|
409
|
/*
|
410
|
* accesssubtree -- table to store access subtree info
|
411
|
*/
|
412
|
CREATE TABLE xml_accesssubtree (
|
413
|
docid VARCHAR2(250), -- the document id #
|
414
|
rev NUMBER(10) DEFAULT 1, --the revision number of the docume
|
415
|
controllevel VARCHAR2(50), -- the level it control -- document or subtree
|
416
|
subtreeid VARCHAR2(250), -- the subtree id
|
417
|
startnodeid NUMBER(20), -- the start node id of access subtree
|
418
|
endnodeid NUMBER(20), -- the end node if of access subtree
|
419
|
CONSTRAINT xml_accesssubtree_docid_fk
|
420
|
FOREIGN KEY (docid) REFERENCES xml_documents
|
421
|
);
|
422
|
|
423
|
/*
|
424
|
* Returnfields -- table to store combinations of returnfields requested
|
425
|
* and the number of times this table is accessed
|
426
|
*/
|
427
|
CREATE TABLE xml_returnfield (
|
428
|
returnfield_id NUMBER(20), -- the id for this returnfield entry
|
429
|
returnfield_string VARCHAR2(2000), -- the returnfield string
|
430
|
usage_count NUMBER(20), -- the number of times this string
|
431
|
-- has been requested
|
432
|
CONSTRAINT xml_returnfield_pk PRIMARY KEY (returnfield_id)
|
433
|
);
|
434
|
CREATE INDEX xml_returnfield_idx1 ON xml_returnfield(returnfield_string);
|
435
|
|
436
|
CREATE SEQUENCE xml_returnfield_id_seq;
|
437
|
|
438
|
CREATE TRIGGER xml_returnfield_before_insert
|
439
|
BEFORE INSERT ON xml_returnfield FOR EACH ROW
|
440
|
BEGIN
|
441
|
SELECT xml_returnfield_id_seq.nextval
|
442
|
INTO :new.returnfield_id
|
443
|
FROM dual;
|
444
|
END;
|
445
|
/
|
446
|
|
447
|
/*
|
448
|
* Queryresults -- table to store queryresults for a given docid
|
449
|
* and returnfield_id
|
450
|
*/
|
451
|
CREATE TABLE xml_queryresult(
|
452
|
queryresult_id NUMBER(20), -- id for this entry
|
453
|
returnfield_id NUMBER(20), -- id for the returnfield corresponding to this entry
|
454
|
docid VARCHAR2(250), -- docid of the document
|
455
|
queryresult_string VARCHAR2(4000), -- resultant text generated for this docid and given
|
456
|
-- returnfield
|
457
|
CONSTRAINT xml_queryresult_pk PRIMARY KEY (queryresult_id),
|
458
|
CONSTRAINT xml_queryresult_searchid_fk
|
459
|
FOREIGN KEY (returnfield_id) REFERENCES xml_returnfield
|
460
|
);
|
461
|
|
462
|
CREATE INDEX xml_queryresult_idx1 ON xml_queryresult (returnfield_id, docid);
|
463
|
|
464
|
CREATE SEQUENCE xml_queryresult_id_seq;
|
465
|
|
466
|
CREATE TRIGGER xml_queryresult_before_insert
|
467
|
BEFORE INSERT ON xml_queryresult FOR EACH ROW
|
468
|
BEGIN
|
469
|
SELECT xml_queryresult_id_seq.nextval
|
470
|
INTO :new.queryresult_id
|
471
|
FROM dual;
|
472
|
END;
|
473
|
/
|
474
|
|
475
|
|
476
|
|
477
|
|
478
|
/*
|
479
|
* Logging -- table to store metadata and data access log
|
480
|
*/
|
481
|
CREATE TABLE access_log (
|
482
|
entryid NUMBER(20), -- the identifier for the log event
|
483
|
ip_address VARCHAR2(512), -- the ip address inititiating the event
|
484
|
principal VARCHAR2(512), -- the user initiiating the event
|
485
|
docid VARCHAR2(250), -- the document id #
|
486
|
event VARCHAR2(512), -- the code symbolizing the event type
|
487
|
date_logged DATE, -- the datetime on which the event occurred
|
488
|
CONSTRAINT access_log_pk PRIMARY KEY (entryid)
|
489
|
);
|
490
|
|
491
|
CREATE SEQUENCE access_log_id_seq;
|
492
|
CREATE TRIGGER access_log_before_insert
|
493
|
BEFORE INSERT ON access_log FOR EACH ROW
|
494
|
BEGIN
|
495
|
SELECT access_log_id_seq.nextval
|
496
|
INTO :new.entryid
|
497
|
FROM dual;
|
498
|
END;
|
499
|
/
|
500
|
|
501
|
/*
|
502
|
* harvest_site_schedule -- table to store harvest sites and schedule info
|
503
|
*/
|
504
|
CREATE TABLE harvest_site_schedule (
|
505
|
site_schedule_id NUMBER, -- unique id
|
506
|
documentlisturl VARCHAR2(255), -- URL of the site harvest document list
|
507
|
ldapdn VARCHAR2(255), -- LDAP distinguished name for site account
|
508
|
datenextharvest DATE, -- scheduled date of next harvest
|
509
|
datelastharvest DATE, -- recorded date of last harvest
|
510
|
updatefrequency NUMBER, -- the harvest update frequency
|
511
|
unit VARCHAR2(50), -- update unit -- days weeks or months
|
512
|
contact_email VARCHAR2(50), -- email address of the site contact person
|
513
|
ldappwd VARCHAR2(20), -- LDAP password for site account
|
514
|
CONSTRAINT harvest_site_schedule_pk PRIMARY KEY (site_schedule_id)
|
515
|
);
|
516
|
|
517
|
/*
|
518
|
* harvest_log -- table to log entries for harvest operations
|
519
|
*/
|
520
|
CREATE TABLE harvest_log (
|
521
|
harvest_log_id NUMBER, -- unique id
|
522
|
harvest_date DATE, -- date of the current harvest
|
523
|
status NUMBER, -- non-zero indicates an error status
|
524
|
message VARCHAR2(1000), -- text message for this log entry
|
525
|
harvest_operation_code VARCHAR2(30), -- the type of harvest operation
|
526
|
site_schedule_id NUMBER, -- site schedule id, or 0 if no site
|
527
|
CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id)
|
528
|
);
|
529
|
|
530
|
/*
|
531
|
* harvest_detail_log -- table to log detailed info about documents that
|
532
|
* generated errors during the harvest
|
533
|
*/
|
534
|
CREATE TABLE harvest_detail_log (
|
535
|
detail_log_id NUMBER, -- unique id
|
536
|
harvest_log_id NUMBER, -- ponter to the related log entry
|
537
|
scope VARCHAR2(50), -- document scope
|
538
|
identifier NUMBER, -- document identifier
|
539
|
revision NUMBER, -- document revision
|
540
|
document_url VARCHAR2(255), -- document URL
|
541
|
error_message VARCHAR2(1000), -- text error message
|
542
|
document_type VARCHAR2(100), -- document type
|
543
|
CONSTRAINT harvest_detail_log_pk PRIMARY KEY (detail_log_id),
|
544
|
CONSTRAINT harvest_detail_log_fk
|
545
|
FOREIGN KEY (harvest_log_id) REFERENCES harvest_log
|
546
|
);
|
547
|
|