Skip to content

Commit

Permalink
Create tables for the university database example
Browse files Browse the repository at this point in the history
See "Database System Concepts" (Silberschatz et al, 6th edition)
appendix for the original DDL and sample data.
  • Loading branch information
asuhan committed Jan 19, 2016
1 parent 1f4869d commit 459c434
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Tests/UniversityExample/advisor.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
s_id,i_id
00128,45565
12345,10101
23121,76543
44553,22222
45678,22222
76543,45565
76653,98345
98765,98345
98988,76766
6 changes: 6 additions & 0 deletions Tests/UniversityExample/classroom.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
building,room_number,capacity
Packard,101,500
Painter,514,10
Taylor,3128,70
Watson,100,30
Watson,120,50
14 changes: 14 additions & 0 deletions Tests/UniversityExample/course.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
course_id,title,dept_name,credits
BIO-101,Intro. to Biology,Biology,4
BIO-301,Genetics,Biology,4
BIO-399,Computational Biology,Biology,3
CS-101,Intro. to Computer Science,Comp. Sci.,4
CS-190,Game Design,Comp. Sci.,4
CS-315,Robotics,Comp. Sci.,3
CS-319,Image Processing,Comp. Sci.,3
CS-347,Database System Concepts,Comp. Sci.,3
EE-181,Intro. to Digital Systems,Elec. Eng.,3
FIN-201,Investment Banking,Finance,3
HIS-351,World History,History,3
MU-199,Music Video Production,Music,3
PHY-101,Physical Principles,Physics,4
22 changes: 22 additions & 0 deletions Tests/UniversityExample/create_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE classroom(building text encoding dict, room_number text encoding dict, capacity smallint) WITH (fragment_size=2);
CREATE TABLE department(dept_name text encoding dict, building text encoding dict, budget text encoding dict) WITH (fragment_size=2);
CREATE TABLE course(course_id text encoding dict, title text encoding dict, dept_name text encoding dict, credits smallint) WITH (fragment_size=2);
CREATE TABLE instructor(ID text encoding dict, name text NOT NULL encoding dict, dept_name text encoding dict, salary integer) WITH (fragment_size=2);
CREATE TABLE section(course_id text encoding dict, sec_id text encoding dict, semester text encoding dict, year smallint, building text encoding dict, room_number text encoding dict, time_slot_id text encoding dict) WITH (fragment_size=2);
CREATE TABLE teaches(ID text encoding dict, course_id text encoding dict, sec_id text encoding dict, semester text encoding dict, year smallint) WITH (fragment_size=2);
CREATE TABLE student(ID text encoding dict, name text NOT NULL encoding dict, dept_name text encoding dict, tot_cred smallint) WITH (fragment_size=2);
CREATE TABLE takes(ID text encoding dict, course_id text encoding dict, sec_id text encoding dict, semester text encoding dict, year smallint, grade text encoding dict) WITH (fragment_size=2);
CREATE TABLE advisor(s_ID text encoding dict, i_ID text encoding dict) WITH (fragment_size=2);
CREATE TABLE prereq(course_id text encoding dict, prereq_id text encoding dict) WITH (fragment_size=2);
CREATE TABLE timeslot(time_slot_id text encoding dict, day text encoding dict, start_time time, end_time time) WITH (fragment_size=2);
COPY classroom FROM './classroom.csv';
COPY department FROM './department.csv';
COPY course FROM './course.csv';
COPY instructor FROM './instructor.csv';
COPY section FROM './section.csv';
COPY teaches FROM './teaches.csv';
COPY student FROM './student.csv';
COPY takes FROM './takes.csv';
COPY advisor FROM './advisor.csv';
COPY prereq FROM './prereq.csv';
COPY timeslot FROM './timeslot.csv';
8 changes: 8 additions & 0 deletions Tests/UniversityExample/department.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dept_name,building,budget
Biology,Watson,90000
Comp. Sci.,Taylor,100000
Elec. Eng.,Taylor,85000
Finance,Painter,120000
History,Painter,50000
Music,Packard,80000
Physics,Watson,70000
13 changes: 13 additions & 0 deletions Tests/UniversityExample/instructor.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ID,name,dept_name,salary
10101,Srinivasan,Comp. Sci.,65000
12121,Wu,Finance,90000
15151,Mozart,Music,40000
22222,Einstein,Physics,95000
32343,El Said,History,60000
33456,Gold,Physics,87000
45565,Katz,Comp. Sci.,75000
58583,Califieri,History,62000
76543,Singh,Finance,80000
76766,Crick,Biology,72000
83821,Brandt,Comp. Sci.,92000
98345,Kim,Elec. Eng.,80000
8 changes: 8 additions & 0 deletions Tests/UniversityExample/prereq.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
course_id,prereq_id
BIO-301,BIO-101
BIO-399,BIO-101
CS-190,CS-101
CS-315,CS-101
CS-319,CS-101
CS-347,CS-101
EE-181,PHY-101
16 changes: 16 additions & 0 deletions Tests/UniversityExample/section.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
course_id,sec_id,semester,year,building,room_number,time_slot_id
BIO-101,1,Summer,2009,Painter,514,B
BIO-301,1,Summer,2010,Painter,514,A
CS-101,1,Fall,2009,Packard,101,H
CS-101,1,Spring,2010,Packard,101,F
CS-190,1,Spring,2009,Taylor,3128,E
CS-190,2,Spring,2009,Taylor,3128,A
CS-315,1,Spring,2010,Watson,120,D
CS-319,1,Spring,2010,Watson,100,B
CS-319,2,Spring,2010,Taylor,3128,C
CS-347,1,Fall,2009,Taylor,3128,A
EE-181,1,Spring,2009,Taylor,3128,C
FIN-201,1,Spring,2010,Packard,101,B
HIS-351,1,Spring,2010,Painter,514,C
MU-199,1,Spring,2010,Packard,101,D
PHY-101,1,Fall,2009,Watson,100,A
14 changes: 14 additions & 0 deletions Tests/UniversityExample/student.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ID,name,dept_name,tot_cred
00128,Zhang,Comp. Sci.,102
12345,Shankar,Comp. Sci.,32
19991,Brandt,History,80
23121,Chavez,Finance,110
44553,Peltier,Physics,56
45678,Levy,Physics,46
54321,Williams,Comp. Sci.,54
55739,Sanchez,Music,38
70557,Snow,Physics,0
76543,Brown,Comp. Sci.,58
76653,Aoi,Elec. Eng.,60
98765,Bourikas,Elec. Eng.,98
98988,Tanaka,Biology,120
23 changes: 23 additions & 0 deletions Tests/UniversityExample/takes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ID,course_id,sec_id,semester,year,grade
00128,CS-101,1,Fall,2009,A
00128,CS-347,1,Fall,2009,A-
12345,CS-101,1,Fall,2009,C
12345,CS-190,2,Spring,2009,A
12345,CS-315,1,Spring,2010,A
12345,CS-347,1,Fall,2009,A
19991,HIS-351,1,Spring,2010,B
23121,FIN-201,1,Spring,2010,C+
44553,PHY-101,1,Fall,2009,B-
45678,CS-101,1,Fall,2009,F
45678,CS-101,1,Spring,2010,B+
45678,CS-319,1,Spring,2010,B
54321,CS-101,1,Fall,2009,A-
54321,CS-190,2,Spring,2009,B+
55739,MU-199,1,Spring,2010,A-
76543,CS-101,1,Fall,2009,A
76543,CS-319,2,Spring,2010,A
76653,EE-181,1,Spring,2009,C
98765,CS-101,1,Fall,2009,C-
98765,CS-315,1,Spring,2010,B
98988,BIO-101,1,Summer,2009,A
98988,BIO-301,1,Summer,2010,\N
16 changes: 16 additions & 0 deletions Tests/UniversityExample/teaches.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ID,course_id,sec_id,semester,year
10101,CS-101,1,Fall,2009
10101,CS-315,1,Spring,2010
10101,CS-347,1,Fall,2009
12121,FIN-201,1,Spring,2010
15151,MU-199,1,Spring,2010
22222,PHY-101,1,Fall,2009
32343,HIS-351,1,Spring,2010
45565,CS-101,1,Spring,2010
45565,CS-319,1,Spring,2010
76766,BIO-101,1,Summer,2009
76766,BIO-301,1,Summer,2010
83821,CS-190,1,Spring,2009
83821,CS-190,2,Spring,2009
83821,CS-319,2,Spring,2010
98345,EE-181,1,Spring,2009
21 changes: 21 additions & 0 deletions Tests/UniversityExample/timeslot.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
time_slot_id,day,start_time,end_time
A,M,8:00:00,8:50:00
A,W,8:00:00,8:50:00
A,F,8:00:00,8:50:00
B,M,9:00:00,9:50:00
B,W,9:00:00,9:50:00
B,F,9:00:00,9:50:00
C,M,11:00:00,11:50:00
C,W,11:00:00,11:50:00
C,F,11:00:00,11:50:00
D,M,13:00:00,13:50:00
D,W,13:00:00,13:50:00
D,F,13:00:00,13:50:00
E,T,10:30:00,11:45:00
E,R,10:30:00,11:45:00
F,T,14:30:00,15:45:00
F,R,14:30:00,15:45:00
G,M,16:00:00,16:50:00
G,W,16:00:00,16:50:00
G,F,16:00:00,16:50:00
H,W,10:00:00,12:30:00

0 comments on commit 459c434

Please sign in to comment.