Browse Source

initial files for a2, no answers yet tho

tsdedhar 6 years ago
commit
7e21c2e2c6
6 changed files with 206 additions and 0 deletions
  1. 83 0
      a2/a2schema.db2
  2. 21 0
      a2/class.txt
  3. 43 0
      a2/database.sql
  4. 20 0
      a2/enrolled.txt
  5. 15 0
      a2/faculty.txt
  6. 24 0
      a2/student.txt

+ 83 - 0
a2/a2schema.db2

@@ -0,0 +1,83 @@
+--
+--  Schema definition for "Student-class-course" A2 (for DB2)
+--
+echo "droping preexisting tables"
+
+drop table department
+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 department ( \
+   deptcode char(2) not null, \
+   deptname varchar(20), \
+   primary key (deptcode))
+
+create table professor ( \
+   pnum     integer not null, \ 
+   pname    varchar(30), \
+   office   char(7), \
+   deptcode char(2), \
+   primary key (pnum), \
+   foreign key (deptcode) references department(deptcode))
+
+create table student ( \
+   snum      integer not null, \
+   sname     varchar(30), \
+   year      integer,  \
+   primary key (snum))
+
+create table course ( \
+   deptcode  char(2) not null, \
+   cnum      integer not null, \
+   cname     varchar(50), \
+   primary key (deptcode,cnum), \
+   foreign key (deptcode) references department(deptcode))
+
+create table class ( \
+   deptcode  char(2) not null, \
+   cnum      integer not null, \
+   term      char(3) not null, \
+   section   integer not null, \
+   pnum      integer, \
+   primary key (deptcode,cnum,term,section), \
+   foreign key (deptcode,cnum) references course(deptcode,cnum), \
+   foreign key (pnum) references professor(pnum))
+
+create table schedule ( \
+   deptcode  char(2) not null, \
+   cnum      integer not null, \
+   term      char(3) not null, \
+   section   integer not null, \
+   day       varchar(10) not null, \
+   time      time not null, \
+   room      char(7), \
+   primary key (deptcode,cnum,term,section,day,time), \
+   foreign key (deptcode,cnum,term,section) references class(deptcode,cnum,term,section))
+
+create table enrollment ( \
+   snum      integer not null, \
+   deptcode  char(2) not null, \
+   cnum      integer not null, \
+   term      char(3) not null, \
+   section   integer not null, \
+   primary key (snum,deptcode,cnum,term,section), \
+   foreign key (snum) references student(snum), \
+   foreign key (deptcode,cnum,term,section) references class(deptcode,cnum,term,section))
+
+create table mark ( \
+   snum      integer not null, \
+   deptcode  char(2) not null, \
+   cnum      integer not null, \
+   term      char(3) not null, \
+   section   integer not null, \
+   grade     integer, \
+   primary key (snum,deptcode,cnum,term,section), \
+   foreign key (snum,deptcode,cnum,term,section) references enrollment(snum,deptcode,cnum,term,section))
+

+ 21 - 0
a2/class.txt

@@ -0,0 +1,21 @@
+Data Structures,MWF 10,R128,489456522
+Database Systems,MWF 12:30-1:45,1320 DCL,142519864
+Operating System Design,TuTh 12-1:20,20 AVW,489456522 
+Archaeology of the Incas,MWF 3-4:15,R128,248965255
+Aviation Accident Investigation,TuTh 1-2:50,Q3,011564812
+Air Quality Engineering,TuTh 10:30-11:45,R15,011564812
+Introductory Latin,MWF 3-4:15,R12,248965255
+American Political Parties,TuTh 2-3:15,20 AVW,619023588
+Social Cognition,Tu 6:30-8:40,R15,159542516
+Perception,MTuWTh 3,Q3,489221823
+Multivariate Analysis,TuTh 2-3:15,R15,090873519
+Patent Law,F 1-2:50,R128,090873519
+Urban Economics,MWF 11,20 AVW,489221823
+Organic Chemistry,TuTh 12:30-1:45,R12,489221823
+Marketing Research,MW 10-11:15,1320 DCL,489221823
+Seminar in American Art,M 4,R15,489221823
+Orbital Mechanics,MWF 8,1320 DCL,011564812
+Dairy Herd Management,TuTh 12:30-1:45,R128,356187925
+Communication Networks,MW 9:30-10:45,20 AVW,141582651
+Optical Electronics,TuTh 12:30-1:45,R15,254099823
+Intoduction to Math,TuTh 8-9:30,R128,489221823

+ 43 - 0
a2/database.sql

@@ -0,0 +1,43 @@
+ DROP TABLE student;
+ DROP TABLE faculty;
+ DROP TABLE class;
+ DROP TABLE enrolled;
+--
+CREATE TABLE student
+  (
+     snum     DECIMAL(9, 0) NOT NULL PRIMARY KEY,
+     sname    VARCHAR(30),
+     major    VARCHAR(25),
+     standing VARCHAR(2),
+     age      DECIMAL(3, 0)
+  );
+
+CREATE TABLE faculty
+  (
+     fid    DECIMAL(9, 0) NOT NULL PRIMARY KEY,
+     fname  VARCHAR(30),
+     deptid DECIMAL(2, 0)
+  );
+
+CREATE TABLE class
+  (
+     name     VARCHAR(40) NOT NULL PRIMARY KEY,
+     meets_at VARCHAR(20),
+     room     VARCHAR(10),
+     fid      DECIMAL(9, 0),
+     FOREIGN KEY(fid) REFERENCES faculty
+  );
+
+CREATE TABLE enrolled
+  (
+     snum  DECIMAL(9, 0) NOT NULL,
+     cname VARCHAR(40) NOT NULL,
+     PRIMARY KEY(snum, cname),
+     FOREIGN KEY(snum) REFERENCES student,
+     FOREIGN KEY(cname) REFERENCES class(name)
+  );
+--
+import from student.txt of del insert into student;
+import from faculty.txt of del insert into faculty;
+import from class.txt of del insert into class;
+import from enrolled.txt of del insert into enrolled;

+ 20 - 0
a2/enrolled.txt

@@ -0,0 +1,20 @@
+112348546,Database Systems
+115987938,Database Systems
+348121549,Database Systems
+322654189,Database Systems
+552455318,Database Systems
+455798411,Operating System Design
+552455318,Operating System Design
+567354612,Operating System Design
+112348546,Operating System Design
+115987938,Operating System Design
+322654189,Operating System Design
+567354612,Data Structures
+552455318,Communication Networks
+455798411,Optical Electronics
+301221823,Perception
+301221823,Social Cognition
+301221823,American Political Parties
+556784565,Air Quality Engineering
+099354543,Patent Law
+574489456,Urban Economics

+ 15 - 0
a2/faculty.txt

@@ -0,0 +1,15 @@
+142519864,Ivana Teach,20
+242518965,James Smith,68
+141582651,Mary Johnson,20
+011564812,John Williams,68
+254099823,Patricia Jones,68
+356187925,Robert Brown,12
+489456522,Linda Davis,20
+287321212,Michael Miller,12
+248965255,Barbara Wilson,12
+159542516,William Moore,33
+090873519,Elizabeth Taylor,11
+486512566,David Anderson,20
+619023588,Jennifer Thomas,11
+489221823,Richard Jackson,33
+548977562,Ulysses Teach,20

+ 24 - 0
a2/student.txt

@@ -0,0 +1,24 @@
+51135593,Maria White,English,SR,21
+60839453,Charles Harris,Architecture,SR,22
+99354543,Susan Martin,Law,JR,20
+112348546,Joseph Thompson,Computer Science,SO,19
+115987938,Christopher Garcia,Computer Science,JR,20
+132977562,Angela Martinez,History,SR,20
+269734834,Thomas Robinson,Psychology,SO,18
+280158572,Margaret Clark,Animal Science,FR,18
+301221823,Juan Rodriguez,Psychology,JR,20
+318548912,Dorthy Lewis,Finance,FR,18
+320874981,Daniel Lee,Electrical Engineering,FR,17
+322654189,Lisa Walker,Computer Science,SO,17
+348121549,Paul Hall,Computer Science,JR,18
+351565322,Nancy Allen,Accounting,JR,19
+451519864,Mark Young,Finance,FR,18
+455798411,Luis Hernandez,Electrical Engineering,FR,17
+462156489,Donald King,Mechanical Engineering,SO,19
+550156548,George Wright,Education,SR,21
+552455318,Ana Lopez,Computer Engineering,SR,19
+556784565,Kenneth Hill,Civil Engineering,SR,21
+567354612,Karen Scott,Computer Engineering,FR,18
+573284895,Steven Green,Kinesiology,SO,19
+574489456,Betty Adams,Economics,JR,20
+578875478,Edward Baker,Veterinary Medicine,SR,21