Created
February 22, 2018 14:58
-
-
Save HelloAlberuni/8fcb27e63e5570836512aedcef50f9e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table department( | |
dept_name varchar(20) not null, | |
building varchar(20) not null, | |
budget numeric(8,2) not null, | |
primary key (dept_name) | |
); | |
create table instructor( | |
id char(5), | |
name varchar(20) not null, | |
dept_name varchar(20) not null, | |
salary numeric(8,0) not null, | |
primary key (id), | |
foreign key (dept_name) references department | |
); | |
create table student( | |
id char(5), | |
name varchar(20) not null, | |
dept_name varchar(20) not null, | |
total_cred numeric(3,0) not null, | |
primary key (id), | |
foreign key (dept_name) references department | |
); | |
create table student( | |
id char(5), | |
name varchar(20) not null, | |
dept_name varchar(20) not null, | |
total_cred numeric(3,0) not null, | |
primary key (id), | |
foreign key (dept_name) references department | |
); | |
create table course( | |
course_id varchar(8), | |
title varchar(50) not null, | |
dept_name varchar(20) not null, | |
credits numeric(2,0) not null, | |
primary key (course_id), | |
foreign key (dept_name) references department | |
); | |
create table takes( | |
id char(5), | |
course_id varchar(8) not null, | |
sec_id varchar(8) not null, | |
semester varchar(6) not null, | |
year numeric(4,0) not null, | |
grade varchar(2) not null, | |
primary key (id,course_id,sec_id,semester,year), | |
foreign key (id) references student, | |
foreign key (course_id,sec_id,semester,year) references student, | |
); | |
create table advisor( | |
s_id char(8), | |
i_id varchar(8), | |
primary key (s_id), | |
foreign key (id) references student, | |
foreign key (id) references instructor | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment