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