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

<!DOCTYPE xmlsql SYSTEM "xmlsql.dtd">

<xmlsql>

<retract construct="table" name="male"/>
<retract construct="table" name="female"/>
<retract construct="table" name="person"/>
<retract construct="table" name="degree"/>
<retract construct="table" name="dept"/>

<update label="create dept">
CREATE TABLE dept 
(  dname VARCHAR(20) NOT NULL,
   CONSTRAINT dept_pk PRIMARY KEY (dname)
)
</update>

<update label="create degree">
CREATE TABLE degree
(  dcode CHAR(4) NOT NULL,
   title VARCHAR(40) NOT NULL,
   dname VARCHAR(20) NOT NULL,
   CONSTRAINT degree_pk PRIMARY KEY (dcode),
   CONSTRAINT degree_runby_dept_fk FOREIGN KEY (dname) REFERENCES dept
)
</update>

<update label="create person">
CREATE TABLE person
(  id INTEGER 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 label="create male">
CREATE TABLE male
(  id INTEGER NOT NULL,
   CONSTRAINT male_pk PRIMARY KEY (id),
   CONSTRAINT male_isa_person_fk FOREIGN KEY (id) REFERENCES person
)
</update>

<update label="create female">
CREATE TABLE female
(  id INTEGER NOT NULL,
   CONSTRAINT female_pk PRIMARY KEY (id),
   CONSTRAINT female_isa_person_fk FOREIGN KEY (id) REFERENCES person
)
</update>

<update>
INSERT INTO dept VALUES ('CS-BBK')
</update>

<update>
INSERT INTO dept VALUES ('Computing-IC')
</update>

<update>
INSERT INTO person VALUES (1,'CS-BBK')
</update>

<update>
INSERT INTO person VALUES (2,'CS-BBK')
</update>

<update>
INSERT INTO person VALUES (3,'Computing-IC')
</update>

<update>
INSERT INTO person VALUES (4,'Computing-IC')
</update>

<update>
INSERT INTO person VALUES (5,'Computing-IC')
</update>

<update>
INSERT INTO female VALUES (1)
</update>

<update>
INSERT INTO male VALUES (2)
</update>

<update>
INSERT INTO male VALUES (3)
</update>

<update>
INSERT INTO female VALUES (4)
</update>

<update>
INSERT INTO male VALUES (5)
</update>

<update>
INSERT INTO degree VALUES ('1234', 'MSc Computing','CS-BBK')
</update>

<update>
INSERT INTO degree VALUES ('G500', 'MEng Computing','Computing-IC')
</update>

<update>
INSERT INTO degree VALUES ('G520', 'MEng Software Engineering','Computing-IC')
</update>

</xmlsql>
