Monday, April 19, 2010

Project #2 Extra Credit: Relational Schema

If you are providing a solution for the extra credit problem, use this script to create your schema in Oracle. Note: since we are providing the schema creation script, you no longer need to include it in your submission!


CREATE TABLE ROOT(
id INT NOT NULL PRIMARY KEY
);

CREATE TABLE NODE(
id INT NOT NULL PRIMARY KEY,
label VARCHAR(200) NOT NULL,
left INT NOT NULL,
right INT NOT NULL,
CONSTRAINT ck_left_right CHECK (left <= right)
);

CREATE TABLE TEXT(
id INT NOT NULL PRIMARY KEY REFERENCES NODE(id),
textValue VARCHAR(2000)
);

CREATE TABLE ATTRIBUTE(
id INT NOT NULL REFERENCES NODE(id),
attribute VARCHAR(200) NOT NULL,
textValue VARCHAR(2000),
CONSTRAINT pk_attribute PRIMARY KEY(id, attribute)
);

No comments:

Post a Comment