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 10 1999-09-13 22:56:17Z 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
|
parentnodeid NUMBER(20),
|
26
|
nodename VARCHAR2(2000),
|
27
|
nodedata VARCHAR2(2000),
|
28
|
date_created DATE,
|
29
|
date_updated DATE,
|
30
|
CONSTRAINT xml_elements_pk PRIMARY KEY (nodeid),
|
31
|
CONSTRAINT xml_elements_parent_fk
|
32
|
FOREIGN KEY (parentnodeid) REFERENCES xml_elements
|
33
|
);
|
34
|
|
35
|
/*
|
36
|
* Documents -- table to store XML document catalog
|
37
|
*/
|
38
|
CREATE TABLE xml_documents (
|
39
|
docid NUMBER(20),
|
40
|
rootnodeid NUMBER(20),
|
41
|
docname VARCHAR2(1000),
|
42
|
doctype VARCHAR2(1000),
|
43
|
date_created DATE,
|
44
|
date_updated DATE,
|
45
|
CONSTRAINT xml_documents_pk PRIMARY KEY (docid),
|
46
|
CONSTRAINT xml_documents_root_fk
|
47
|
FOREIGN KEY (rootnodeid) REFERENCES xml_elements
|
48
|
);
|
49
|
|
50
|
/*
|
51
|
* Attributes -- table to store XML Attributes
|
52
|
*/
|
53
|
CREATE TABLE xml_attributes (
|
54
|
attributeid NUMBER(20),
|
55
|
nodeid NUMBER(20),
|
56
|
attributenumber NUMBER(20),
|
57
|
attributename VARCHAR2(2000),
|
58
|
attributevalue VARCHAR2(2000),
|
59
|
date_created DATE,
|
60
|
date_updated DATE,
|
61
|
CONSTRAINT xml_attributes_pk PRIMARY KEY (attributeid),
|
62
|
CONSTRAINT xml_attributes_parent_node FOREIGN KEY (nodeid)
|
63
|
REFERENCES xml_elements
|
64
|
);
|