1
|
/*
|
2
|
* xmltables.sql -- Create or replace tables for storing XML in the db
|
3
|
*
|
4
|
* Purpose: creates tables needed for XML database
|
5
|
*
|
6
|
* Created: 12 September 1999
|
7
|
* Author: Matt Jones
|
8
|
* Organization: National Center for Ecological Analysis and Synthesis
|
9
|
* Version: '$Id: xmltables.sql 5 1999-09-12 20:20:16Z jones $'
|
10
|
*
|
11
|
*/
|
12
|
|
13
|
/*
|
14
|
* Drop all of the tables in proper order
|
15
|
*/
|
16
|
DROP TABLE xml_documents;
|
17
|
DROP TABLE xml_attributes;
|
18
|
DROP TABLE xml_elements;
|
19
|
|
20
|
/*
|
21
|
* Elements -- table to store XML Elements
|
22
|
*/
|
23
|
CREATE TABLE xml_elements (
|
24
|
nodeid NUMBER(20),
|
25
|
nodename VARCHAR2(2000),
|
26
|
nodedata VARCHAR2(2000),
|
27
|
date_created DATE,
|
28
|
date_updated DATE,
|
29
|
CONSTRAINT xml_elements_pk PRIMARY KEY (nodeid)
|
30
|
);
|
31
|
|
32
|
/*
|
33
|
* Documents -- table to store XML document catalog
|
34
|
*/
|
35
|
CREATE TABLE xml_documents (
|
36
|
docid NUMBER(20),
|
37
|
rootnodeid NUMBER(20),
|
38
|
docname VARCHAR2(1000),
|
39
|
doctype VARCHAR2(1000),
|
40
|
date_created DATE,
|
41
|
date_updated DATE,
|
42
|
CONSTRAINT xml_documents_pk PRIMARY KEY (docid),
|
43
|
CONSTRAINT xml_documents_root_fk
|
44
|
FOREIGN KEY (rootnodeid) REFERENCES xml_elements
|
45
|
);
|
46
|
|
47
|
/*
|
48
|
* Attributes -- table to store XML Attributes
|
49
|
*/
|
50
|
CREATE TABLE xml_attributes (
|
51
|
attributeid NUMBER(20),
|
52
|
nodeid NUMBER(20),
|
53
|
attributenumber NUMBER(20),
|
54
|
attributename VARCHAR2(2000),
|
55
|
attributevalue VARCHAR2(2000),
|
56
|
date_created DATE,
|
57
|
date_updated DATE,
|
58
|
CONSTRAINT xml_attributes_pk PRIMARY KEY (attributeid),
|
59
|
CONSTRAINT xml_attributes_parent_node FOREIGN KEY (nodeid)
|
60
|
REFERENCES xml_elements
|
61
|
);
|