Project

General

Profile

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