<?xml version="1.0" standalone="no"?>

<!DOCTYPE xmlsql SYSTEM "xmlsql.dtd">

<xmlsql>

<retract construct="table" name="person"/>
<retract construct="table" name="dept"/>
<retract construct="table" name="college"/>
<retract construct="table" name="university"/>

<update label="create university">
CREATE TABLE university
(  uname VARCHAR(20) NOT NULL,
   CONSTRAINT university_pk PRIMARY KEY (uname)
)
</update>

<update label="create college">
CREATE TABLE college
(  cname VARCHAR(20) NOT NULL,
   uname VARCHAR(20) NOT NULL,
   CONSTRAINT college_pk PRIMARY KEY (cname),
   CONSTRAINT college_partof_university_fk 
       FOREIGN KEY (uname) REFERENCES university
)
</update>

<update label="create dept">
CREATE TABLE dept 
(  dname VARCHAR(20) NOT NULL,
   street VARCHAR(20) NOT NULL,
   cname VARCHAR(20) NOT NULL,
   CONSTRAINT dept_pk PRIMARY KEY (dname),
   CONSTRAINT dept_partof_college_fk FOREIGN KEY (cname) REFERENCES college
)
</update>

<update label="create person">
CREATE TABLE person
(  id INTEGER NOT NULL,
   name VARCHAR(20) NOT NULL,
   sex CHAR(1) NOT NULL,
   dname VARCHAR(20) NOT NULL,
   CONSTRAINT person_pk PRIMARY KEY (id),
   CONSTRAINT person_worksin_dept_fk FOREIGN KEY (dname) REFERENCES dept
)
</update>

<update>
INSERT INTO university VALUES ('London')
</update>

<update>
INSERT INTO university VALUES ('Manchester')
</update>

<update>
INSERT INTO university VALUES ('Cambridge')
</update>

<update>
INSERT INTO college VALUES ('UCL','London')
</update>

<update>
INSERT INTO college VALUES ('IC','London')
</update>

<update>
INSERT INTO college VALUES ('Kings','London')
</update>

<update>
INSERT INTO dept VALUES ('CS-UCL','Gower St','UCL')
</update>

<update>
INSERT INTO dept VALUES ('CS-Kings','Strand','Kings')
</update>

<update>
INSERT INTO dept VALUES ('Physics-IC','Queens Gate','IC')
</update>

<update>
INSERT INTO person VALUES (10,'Tony','M','CS-UCL')
</update>

<update>
INSERT INTO person VALUES (11,'Neil','M','CS-Kings')
</update>

<update>
INSERT INTO person VALUES (14,'Nahed','F','CS-Kings')
</update>

<update>
INSERT INTO person VALUES (15,'Dov','M','CS-Kings')
</update>

<update>
INSERT INTO person VALUES (16,'Tom','M','CS-Kings')
</update>

</xmlsql>
