NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


create table classroom
(building varchar (15),
room_number varchar (7),
capacity numeric (4,0),
primary key (building, room_number));

create table department
(dept_name varchar (20) not null,
building varchar (15),
budget numeric (12,2) check (budget > 0),
primary key (dept_name));

create table course
(course_id varchar(8),
title varchar(50),
dept_name varchar(20),
credits numeric(2,0) check (credits > 0),
primary key(course_id),
foreign key(dept_name)references department(dept_name)
on delete set null);

create table instructor
(ID varchar (5),
name varchar (20) not null,
dept_name varchar (20),
salary numeric (8,2) check (salary > 29000),
primary key (ID),
foreign key (dept_name) references department(dept_name)
on delete set null);

create table section
(course_id varchar (8),
sec_id varchar (8),
semester varchar (6) check (semester in
('Fall', 'Winter', 'Spring', 'Summer')),
year numeric (4,0) check (year > 1701 and year < 2100),
building varchar (15),
room_number varchar (7),
time_slot_id varchar (4),
primary key (course_id, sec_id, semester, year),
foreign key (course_id) references course (course_id) on delete cascade,
foreign key (building, room_number) references classroom (building, room_number) on delete set null);

create table teaches(
ID varchar(5),
course_id varchar(8),
sec_id varchar(8),
semester varchar(6),
year numeric(4,0),
primary key(ID,course_id,sec_id,semester,year),
foreign key(course_id,sec_id,semester,year)references section(course_id,sec_id,semester,year) on delete cascade,
foreign key(ID)references instructor(ID) on delete cascade);

create table student
(ID varchar (5),
name varchar (20) not null,
dept_name varchar (20),
tot_cred numeric (3,0) check (tot_cred >= 0),
primary key (ID),
foreign key (dept_name) references department(dept_name)
on delete set null);

create table takes(
ID varchar(5),
course_id varchar(8),
sec_id varchar(8),
semester varchar(6),
year numeric(4,0),
grade varchar(2),
primary key(ID,course_id,sec_id,semester,year),
foreign key(course_id,sec_id,semester,year)references section(course_id,sec_id,semester,year),
foreign key(ID)references student(ID) on delete cascade);

create table advisor
(s_ID varchar (5),
i_ID varchar (5),
primary key (s_ID),
foreign key (i_ID) references instructor (ID)
on delete set null,
foreign key (s_ID) references student (ID)
on delete cascade);

create table prereq(
course_id varchar(8),
prereq_id varchar(8),
primary key(course_id,prereq_id),
foreign key(course_id)references course(course_id) on delete cascade,
foreign key(prereq_id)references course(course_id));

create table timeslot
(time_slot_id varchar (4),
day varchar (1) check (day in ('M', 'T', 'W', 'R', 'F', 'S', 'U')),
start_time time,
end_time time,
primary key (time_slot_id, day, start_time));


- 1. TABLE classroom
-- building varchar (15), room_number varchar (7), capacity numeric (4,0)

INSERT INTO classroom (building, room_number, capacity) VALUES ('Packard', '101', 500);
INSERT INTO classroom VALUES ('Painter', '514', 10);
INSERT INTO classroom VALUES ('Taylor','3128', 70);
INSERT INTO classroom VALUES ('Watson', '100', 30);
INSERT INTO classroom VALUES ('Watson', '120', 50);

-- 2. TABLE department
-- dept_name varchar (20), building varchar (15), budget numeric (12,2)

INSERT INTO department (dept_name, building, budget) VALUES ('Biology', 'Watson', 90000);
INSERT INTO department VALUES ('Comp. Sci.', 'Taylor', 100000);
INSERT INTO department VALUES ('Elec. Eng.', 'Taylor', 85000);
INSERT INTO department VALUES ('Finance', 'Painter', 120000);
INSERT INTO department VALUES ('History', 'Painter', 50000);
INSERT INTO department VALUES ('Music', 'Packard',80000);
INSERT INTO department VALUES ('Physics', 'Watson', 70000);

-- 3. TABLE course
-- course_id varchar(8), title varchar(50), dept_name varchar(20), credits numeric(2,0)

INSERT INTO course (course_id, title, dept_name, credits) VALUES ('BIO-101', 'Intro. to Biology', 'Biology', 4);
INSERT INTO course VALUES ('BIO-301', 'Genetics', 'Biology', 4);
INSERT INTO course VALUES ('BIO-399', 'Computational Biology', 'Biology', 3);
INSERT INTO course VALUES ('CS-101', 'Intro. to Computer Science', 'Comp. Sci.', 4);
INSERT INTO course VALUES ('CS-190', 'Game Design', 'Comp. Sci.', 4);
INSERT INTO course VALUES ('CS-315', 'Robotics', 'Comp. Sci.', 3);
INSERT INTO course VALUES ('CS-319', 'Image Processing', 'Comp. Sci.', 3);
INSERT INTO course VALUES ('CS-347', 'Database System Concepts', 'Comp. Sci.', 3);
INSERT INTO course VALUES ('EE-181', 'Intro. to Digital Systems', 'Elec. Eng.', 3);
INSERT INTO course VALUES ('FIN-201', 'Investment Banking', 'Finance', 3);
INSERT INTO course VALUES ('HIS-351', 'World History', 'History', 3);
INSERT INTO course VALUES ('MU-199', 'Music Video Production','Music', 3);
INSERT INTO course VALUES ('PHY-101', 'Physical Principles', 'Physics', 4);

-- 4. TABLE instructor
-- ID varchar (5), name varchar (20), dept_name varchar (20), salary numeric (8,2)

INSERT INTO instructor (ID, name, dept_name, salary) VALUES ('10101', 'Srinivasan', 'Comp. Sci.', 65000);
INSERT INTO instructor VALUES ('12121', 'Wu', 'Finance', 90000);
INSERT INTO instructor VALUES ('15151', 'Mozart', 'Music', 40000);
INSERT INTO instructor VALUES ('22222', 'Einstein', 'Physics', 95000);
INSERT INTO instructor VALUES ('32343', 'El Said', 'History', 60000);
INSERT INTO instructor VALUES ('33456', 'Gold', 'Physics', 87000);
INSERT INTO instructor VALUES ('45565', 'Katz', 'Comp. Sci.', 75000);
INSERT INTO instructor VALUES ('58583', 'Califieri', 'History', 62000);
INSERT INTO instructor VALUES ('76543', 'Singh', 'Finance', 80000);
INSERT INTO instructor VALUES ('76766', 'Crick', 'Biology', 72000);
INSERT INTO instructor VALUES ('83821', 'Brandt', 'Comp. Sci.', 92000);
INSERT INTO instructor VALUES ('98345', 'Kim', 'Elec. Eng.', 80000);

-- 5. TABLE section
-- course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), building varchar(15), room_number varchar(7),time_slot_id varchar(4)

INSERT INTO section (course_id, sec_id, semester, year, building, room_number, time_slot_id) VALUES ('BIO-101', '1', 'Summer', 2009, 'Painter', '514', 'B');
INSERT INTO section VALUES ('BIO-301', '1', 'Summer', 2010, 'Painter', '514', 'A');
INSERT INTO section VALUES ('CS-101', '1', 'Fall', 2009, 'Packard', '101', 'H');
INSERT INTO section VALUES ('CS-101', '1', 'Spring', 2010, 'Packard', '101', 'F');
INSERT INTO section VALUES ('CS-190', '1', 'Spring', 2009, 'Taylor', '3128', 'E');
INSERT INTO section VALUES ('CS-190', '2', 'Spring', 2009, 'Taylor', '3128', 'A');
INSERT INTO section VALUES ('CS-315', '1', 'Spring', 2010, 'Watson', '120', 'D');
INSERT INTO section VALUES ('CS-319', '1', 'Spring', 2010, 'Watson', '100', 'B');
INSERT INTO section VALUES ('CS-319', '2', 'Spring', 2010, 'Taylor', '3128', 'C');
INSERT INTO section VALUES ('CS-347', '1', 'Fall', 2009, 'Taylor', '3128', 'A');
INSERT INTO section VALUES ('EE-181', '1', 'Spring', 2009, 'Taylor', '3128', 'C');
INSERT INTO section VALUES ('FIN-201', '1', 'Spring', 2010, 'Packard', '101', 'B');
INSERT INTO section VALUES ('HIS-351', '1', 'Spring', 2010, 'Painter', '514', 'C');
INSERT INTO section VALUES ('MU-199', '1', 'Spring', 2010, 'Packard', '101', 'D');
INSERT INTO section VALUES ('PHY-101', '1', 'Fall', 2009, 'Watson', '100', 'A');

-- 6. TABLE teaches
-- ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0)

INSERT INTO teaches (ID, course_id, sec_id, semester, year) VALUES ('10101', 'CS-101', '1','Fall', 2009);
INSERT INTO teaches VALUES ('10101', 'CS-315', '1', 'Spring', 2010);
INSERT INTO teaches VALUES ('10101', 'CS-347', '1', 'Fall', 2009);
INSERT INTO teaches VALUES ('12121', 'FIN-201', '1', 'Spring', 2010);
INSERT INTO teaches VALUES ('15151', 'MU-199', '1', 'Spring', 2010);
INSERT INTO teaches VALUES ('22222', 'PHY-101', '1', 'Fall', 2009);
INSERT INTO teaches VALUES ('32343', 'HIS-351', '1', 'Spring', 2010);
INSERT INTO teaches VALUES ('45565', 'CS-101', '1', 'Spring', 2010);
INSERT INTO teaches VALUES ('45565', 'CS-319', '1', 'Spring', 2010);
INSERT INTO teaches VALUES ('76766', 'BIO-101', '1', 'Summer', 2009);
INSERT INTO teaches VALUES ('76766', 'BIO-301', '1', 'Summer', 2010);
INSERT INTO teaches VALUES ('83821', 'CS-190', '1', 'Spring', 2009);
INSERT INTO teaches VALUES ('83821', 'CS-190', '2', 'Spring', 2009);
INSERT INTO teaches VALUES ('83821', 'CS-319', '2', 'Spring', 2010);
INSERT INTO teaches VALUES ('98345', 'EE-181', '1', 'Spring', 2009);

-- 7. TABLE student
-- ID varchar (5), name varchar (20), dept_name varchar (20), tot_cred numeric (3,0)

INSERT INTO student (ID, name, dept_name, tot_cred) VALUES ('00128', 'Zhang', 'Comp. Sci.', 102);
INSERT INTO student VALUES ('12345', 'Shankar', 'Comp. Sci.', 32);
INSERT INTO student VALUES ('19991', 'Brandt', 'History', 80);
INSERT INTO student VALUES ('23121', 'Chavez', 'Finance', 110);
INSERT INTO student VALUES ('44553', 'Peltier', 'Physics', 56);
INSERT INTO student VALUES ('45678', 'Levy', 'Physics', 46);
INSERT INTO student VALUES ('54321', 'Williams', 'Comp. Sci.', 54);
INSERT INTO student VALUES ('55739', 'Sanchez', 'Music', 38);
INSERT INTO student VALUES ('70557', 'Snow', 'Physics', 0);
INSERT INTO student VALUES ('76543', 'Brown', 'Comp. Sci.', 58);
INSERT INTO student VALUES ('76653', 'Aoi', 'Elec. Eng.', 60);
INSERT INTO student VALUES ('98765', 'Bourikas', 'Elec. Eng.', 98);
INSERT INTO student VALUES ('98988', 'Tanaka', 'Biology', 120);

-- 8. TABLE takes
-- ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), grade varchar(2)

INSERT INTO takes (ID, course_id, sec_id, semester, year, grade) VALUES ('00128', 'CS-101', '1', 'Fall', 2009, 'A');
INSERT INTO takes VALUES ('00128', 'CS-347', '1', 'Fall', 2009 , 'A-');
INSERT INTO takes VALUES ('12345', 'CS-101', '1', 'Fall', 2009 , 'C');
INSERT INTO takes VALUES ('12345', 'CS-190', '2', 'Spring', 2009 , 'A');
INSERT INTO takes VALUES ('12345', 'CS-315', '1', 'Spring', 2010 , 'A');
INSERT INTO takes VALUES ('12345', 'CS-347', '1', 'Fall', 2009 , 'A');
INSERT INTO takes VALUES ('19991', 'HIS-351', '1', 'Spring', 2010 , 'B');
INSERT INTO takes VALUES ('23121', 'FIN-201', '1', 'Spring', 2010 , 'C+');
INSERT INTO takes VALUES ('44553', 'PHY-101', '1', 'Fall', 2009 , 'B-');
INSERT INTO takes VALUES ('45678', 'CS-101', '1', 'Fall', 2009 , 'F');
INSERT INTO takes VALUES ('45678', 'CS-101', '1', 'Spring', 2010 , 'B+');
INSERT INTO takes VALUES ('45678', 'CS-319', '1', 'Spring', 2010 , 'B');
INSERT INTO takes VALUES ('54321', 'CS-101', '1', 'Fall', 2009 , 'A-');
INSERT INTO takes VALUES ('54321', 'CS-190', '2', 'Spring', 2009 , 'B+');
INSERT INTO takes VALUES ('55739', 'MU-199', '1', 'Spring', 2010 , 'A-');
INSERT INTO takes VALUES ('76543', 'CS-101', '1', 'Fall', 2009 , 'A');
INSERT INTO takes VALUES ('76543', 'CS-319', '2', 'Spring', 2010, 'A');
INSERT INTO takes VALUES ('76653', 'EE-181', '1', 'Spring', 2009 , 'C');
INSERT INTO takes VALUES ('98765', 'CS-101', '1', 'Fall', 2009 , 'C-');
INSERT INTO takes VALUES ('98765', 'CS-315', '1', 'Spring', 2010 , 'B');
INSERT INTO takes VALUES ('98988', 'BIO-101', '1', 'Summer', 2009 , 'A');
INSERT INTO takes VALUES ('98988', 'BIO-301', '1', 'Summer', 2010 , NULL);

-- 9. TABLE advisor
-- s_ID varchar (5), i_ID varchar (5)

INSERT INTO advisor (s_ID, i_ID) VALUES ('00128', '45565');
INSERT INTO advisor VALUES ('12345', '10101');
INSERT INTO advisor VALUES ('23121', '76543');
INSERT INTO advisor VALUES ('44553', '22222');
INSERT INTO advisor VALUES ('45678', '22222');
INSERT INTO advisor VALUES ('76543', '45565');
INSERT INTO advisor VALUES ('76653', '98345');
INSERT INTO advisor VALUES ('98765', '98345');
INSERT INTO advisor VALUES ('98988', '76766');

-- 10. TABLE prereq
-- course_id varchar(8), prereq_id varchar(8)

INSERT INTO prereq (course_id, prereq_id) VALUES ('BIO-301', 'BIO-101');
INSERT INTO prereq VALUES ('BIO-399', 'BIO-101');
INSERT INTO prereq VALUES ('CS-190', 'CS-101');
INSERT INTO prereq VALUES ('CS-315', 'CS-101');
INSERT INTO prereq VALUES ('CS-319', 'CS-101');
INSERT INTO prereq VALUES ('CS-347', 'CS-101');
INSERT INTO prereq VALUES ('EE-181', 'PHY-101');

-- 11 TABLE timeslot
-- time_slot_id varchar (4), day varchar (1), start_time time, end_time time

INSERT INTO timeslot (time_slot_id, day, start_time, end_time) VALUES ('A', 'M', '8:00:00', '8:50:00');
INSERT INTO timeslot VALUES ('A', 'W', '8:00:00', '8:50:00');
INSERT INTO timeslot VALUES ('A', 'F', '8:00:00', '8:50:00');
INSERT INTO timeslot VALUES ('B', 'M', '9:00:00', '9:50:00');
INSERT INTO timeslot VALUES ('B', 'W', '9:00:00', '9:50:00');
INSERT INTO timeslot VALUES ('B', 'F', '9:00:00', '9:50:00');
INSERT INTO timeslot VALUES ('C', 'M', '11:00:00', '11:50:00');
INSERT INTO timeslot VALUES ('C', 'W', '11:00:00', '11:50:00');
INSERT INTO timeslot VALUES ('C', 'F', '11:00:00', '11:50:00');
INSERT INTO timeslot VALUES ('D', 'M', '13:00:00', '13:50:00');
INSERT INTO timeslot VALUES ('D', 'W', '13:00:00', '13:50:00');
INSERT INTO timeslot VALUES ('D', 'F', '13:00:00', '13:50:00');
INSERT INTO timeslot VALUES ('E', 'T', '10:30:00', '11:45:00');
INSERT INTO timeslot VALUES ('E', 'R', '10:30:00', '11:45:00');
INSERT INTO timeslot VALUES ('F', 'T', '14:30:00', '15:45:00');
INSERT INTO timeslot VALUES ('F', 'R', '14:30:00', '15:45:00');
INSERT INTO timeslot VALUES ('G', 'M', '16:00:00', '16:50:00');
INSERT INTO timeslot VALUES ('G', 'W', '16:00:00', '16:50:00');
INSERT INTO timeslot VALUES ('G', 'F', '16:00:00', '16:50:00');
INSERT INTO timeslot VALUES ('H', 'W', '10:00:00', '12:30:00');
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.