1 |
2
|
jones
|
/*
|
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$'
|
10 |
|
|
*
|
11 |
|
|
*/
|
12 |
|
|
|
13 |
5
|
jones
|
/*
|
14 |
|
|
* Drop all of the tables in proper order
|
15 |
2
|
jones
|
*/
|
16 |
5
|
jones
|
DROP TABLE xml_documents;
|
17 |
|
|
DROP TABLE xml_attributes;
|
18 |
|
|
DROP TABLE xml_elements;
|
19 |
3
|
jones
|
|
20 |
|
|
/*
|
21 |
|
|
* Elements -- table to store XML Elements
|
22 |
|
|
*/
|
23 |
5
|
jones
|
CREATE TABLE xml_elements (
|
24 |
3
|
jones
|
nodeid NUMBER(20),
|
25 |
10
|
jones
|
parentnodeid NUMBER(20),
|
26 |
3
|
jones
|
nodename VARCHAR2(2000),
|
27 |
|
|
nodedata VARCHAR2(2000),
|
28 |
|
|
date_created DATE,
|
29 |
|
|
date_updated DATE,
|
30 |
10
|
jones
|
CONSTRAINT xml_elements_pk PRIMARY KEY (nodeid),
|
31 |
|
|
CONSTRAINT xml_elements_parent_fk
|
32 |
|
|
FOREIGN KEY (parentnodeid) REFERENCES xml_elements
|
33 |
3
|
jones
|
);
|
34 |
|
|
|
35 |
|
|
/*
|
36 |
5
|
jones
|
* 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 |
3
|
jones
|
* Attributes -- table to store XML Attributes
|
52 |
|
|
*/
|
53 |
5
|
jones
|
CREATE TABLE xml_attributes (
|
54 |
3
|
jones
|
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 |
5
|
jones
|
CONSTRAINT xml_attributes_pk PRIMARY KEY (attributeid),
|
62 |
|
|
CONSTRAINT xml_attributes_parent_node FOREIGN KEY (nodeid)
|
63 |
|
|
REFERENCES xml_elements
|
64 |
3
|
jones
|
);
|