You are on page 1of 2

#1 # #select distinct title #from course, section as s1, section as s2 #where course.course_id = s1.course_id and s1.course_id = s2.

course_id and s1.ye ar = s2.year and s1.semester = s2.semester and s1.time_slot_id <> s2.time_slot_i d # #select distinct name #from instructor ,teaches as t1, teaches as t2, teaches as t3, teaches as t4, te aches as t5 #where instructor.id = t1.id and t1.id = t2.id and t2.id = t3.id and t3.id = t4. id and t4.id = t5.id and # t1.semester = t2.semester and t2.semester = t3.semester and t3.semester = t4.semester and t4.semester = t5.semester and # t1.course_id <> t2.course_id and t1.course_id <> t3.course_id and t1.cour se_id <> t4.course_id and t1.course_id <> t5.course_id and # t2.course_id <> t3.course_id and t2.course_id <> t4.course_id and t2.cour se_id <> t5.course_id and # t3.course_id <> t4.course_id and t3.course_id <> t5.course_id and # t4.course_id <> t5.course_id # #select distinct name #from student, advisor #where id <> all (select s_id from advisor) and tot_cred > 50 # #select title, course.course_id, time_slot_id #from department, course, section #where department.dept_name = course.dept_name and course.course_id = section.co urse_id and department.building <> section.building # #select distinct * fix!! #from takes as t1, takes as t2, prereq, student #where t1.id = t2.id and student.id = t1.id and prereq_id is not null and #prereq.course_id = t1.course_id and t1.course_id = t2.course_id and #prereq_id <> all # (select distinct course_id # from takes # where takes.id = student.id and takes.id = t1.id and takes.id = t2.id and # takes.course_id = t1.course_id and takes.course_id = t2.course _id) # #select distinct name,avg(credits) #from student natural join takes natural join course #group by name # # select distinct year, semester, title from takes natural join course

where #2 # #create table submited_exercises #(id varchar(9), #course_id varchar(8), #exercise_no varchar(2), #submission_date date, #grade varchar(2), #primary key (id, course_id, grade) #); # #insert into submited_exercises #select id, course_id, null, null, grade #from takes #where year = '2010' and semester = 'spring' # #create table current_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 #); #insert into current_instructor #select id, name, dept_name, salary #from instructor natural join teaches #where year = '2010'

You might also like