Schema definition for Studentclasscourse A2 for DB2
echo droping preexisting tables
drop table professor
drop table student
drop table course
drop table class
drop table schedule
drop table enrollment
drop table mark
echo creating tables
create table professor
pnum integer not null,
pname varchar30 not null,
office char7 not null,
dept char2 not null,
primary key pnum
create table student
snum integer not null,
sname varchar30 not null,
year integer not null,
primary key snum
create table course
cnum char6 not null,
cname varchar50 not null,
primary key cnum
create table class
cnum char6 not null,
term char3 not null,
section integer not null,
pnum integer not null,
primary key cnum,term,section,
foreign key cnum references coursecnum,
foreign key pnum references professorpnum
create table schedule
cnum char6 not null,
term char3 not null,
section integer not null,
day varchar10 not null,
time time not null,
room char7 not null,
primary key cnum,term,section,day,time,
foreign key cnum,term,section references classcnum,term,section
create table enrollment
snum integer not null,
cnum char6 not null,
term char3 not null,
section integer not null,
primary key snum,cnum,term,section,
foreign key snum references studentsnum,
foreign key cnum,term,section references classcnum,term,section
create table mark
snum integer not null,
cnum char6 not null,
term char3 not null,
section integer not null,
grade integer not null,
primary key snum,cnum,term,section,
foreign key snum,cnum,term,section references enrollmentsnum,cnum,term,section