Project

General

Profile

« Previous | Next » 

Revision 5

changed order of operations for table creates

View differences:

xmltables.sql
10 10
 *
11 11
 */
12 12

  
13
/* 
14
 * Documents -- table to store XML document catalog
13
/*
14
 * Drop all of the tables in proper order
15 15
 */
16
DROP TABLE documents;
17
CREATE TABLE documents (
18
	docid		NUMBER(20),
19
	rootnodeid	NUMBER(20),
20
	docname		VARCHAR2(1000),
21
	doctype		VARCHAR2(1000),
22
	date_created	DATE,
23
	date_updated	DATE,
24
   CONSTRAINT document_pk PRIMARY KEY (docid),
25
   CONSTRAINT fk_root_node FOREIGN KEY (rootnodeid) REFERENCES elements
26
);
16
DROP TABLE xml_documents;
17
DROP TABLE xml_attributes;
18
DROP TABLE xml_elements;
27 19

  
28 20
/* 
29 21
 * Elements -- table to store XML Elements
30 22
 */
31
DROP TABLE elements;
32
CREATE TABLE elements (
23
CREATE TABLE xml_elements (
33 24
	nodeid		NUMBER(20),
34 25
	nodename	VARCHAR2(2000),
35 26
	nodedata	VARCHAR2(2000),
36 27
	date_created	DATE,
37 28
	date_updated	DATE,
38
   CONSTRAINT elements_pk PRIMARY KEY (nodeid)
29
   CONSTRAINT xml_elements_pk PRIMARY KEY (nodeid)
39 30
);
40 31

  
41 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
/* 
42 48
 * Attributes -- table to store XML Attributes
43 49
 */
44
DROP TABLE attributes;
45
CREATE TABLE attributes (
50
CREATE TABLE xml_attributes (
46 51
	attributeid	NUMBER(20),
47 52
	nodeid		NUMBER(20),
48 53
	attributenumber	NUMBER(20),
......
50 55
	attributevalue	VARCHAR2(2000),
51 56
	date_created	DATE,
52 57
	date_updated	DATE,
53
   CONSTRAINT KEY (attributeid),
54
   CONSTRAINT fk_parent_node FOREIGN KEY (nodeid) REFERENCES elements
58
   CONSTRAINT xml_attributes_pk PRIMARY KEY (attributeid),
59
   CONSTRAINT xml_attributes_parent_node FOREIGN KEY (nodeid) 
60
		REFERENCES xml_elements
55 61
);

Also available in: Unified diff