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 |
|
|
nodename VARCHAR2(2000),
|
26 |
|
|
nodedata VARCHAR2(2000),
|
27 |
|
|
date_created DATE,
|
28 |
|
|
date_updated DATE,
|
29 |
5
|
jones
|
CONSTRAINT xml_elements_pk PRIMARY KEY (nodeid)
|
30 |
3
|
jones
|
);
|
31 |
|
|
|
32 |
|
|
/*
|
33 |
5
|
jones
|
* 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 |
3
|
jones
|
* Attributes -- table to store XML Attributes
|
49 |
|
|
*/
|
50 |
5
|
jones
|
CREATE TABLE xml_attributes (
|
51 |
3
|
jones
|
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 |
5
|
jones
|
CONSTRAINT xml_attributes_pk PRIMARY KEY (attributeid),
|
59 |
|
|
CONSTRAINT xml_attributes_parent_node FOREIGN KEY (nodeid)
|
60 |
|
|
REFERENCES xml_elements
|
61 |
3
|
jones
|
);
|