Professional Documents
Culture Documents
1.
create procedure d_student(in name varchar(50)) begin select * from student where student.name=name; end $;
call d_student('Tanaka')$;
2.
create procedure kampus(in name varchar(50)) begin select name,title from course natural join takes natural join student where course.course_id=takes.course_id and takes.id=student.id and student.name=name; end$; call kampus(Sanchez)$;
Page 1
KBD Procedure
3.
create procedure daftar_makul(in name varchar(50),semester varchar(6)) begin select name,semester,title from course natural join takes natural join student where takes.id=student.id and student.name=name and takes.semester=semester; end$; call daftar_makul('Chavez','Spring')$;
4.
create procedure section_course(in year char(4)) begin select * from section, course where section.course_id=course.course_id and section.year=year; end$; call section_course(2010)$;
Page 2
KBD Procedure
5.
create procedure jumlah_instructor(in semester varchar(6)) begin select semester,course_id,count(distinct id) from course natural join teaches where teaches.semester=semester group by course_id; end$; call jumlah_instructor(Fall)$;
6.
create procedure rata_salary(in dept_name varchar(20)) begin select dept_name,avg(salary) from department natural join instructor where department.dept_name=dept_name group by dept_name; end$;
Page 3
KBD Procedure
call rata_salary('Physic')$;
7.
create procedure jml_totcred(in name varchar(50)) begin select name,sum(tot_cred) from student where student.name=name group by name; end$; call jml_totcred('Aoi')$;
8.
create procedure inst_semester(in semester varchar(6), year char(4)) begin select semester,year,name from instructor natural right join teaches where teaches.semester=semester and teaches.year=year; end$; call inst_semester('Fall',2009)$;
Page 4
KBD Procedure
9.
create procedure stud_grade(in name varchar(50)) begin select name,course_id,semester,year,grade from student natural right join takes where student.name=name; end$; call stud_grade('Aoi')$;
10.
create procedure max_cred(in dept_name varchar(20)) begin select dept_name,max(credits) from department natural join course where department.dept_name=dept_name group by dept_name; end$; call max_cred('Comp.Sci')$;
Page 5
KBD Procedure
11.
create procedure makul_belum(in name varchar(50)) begin select course_id,title from course where (course_id) not in(select course_id from takes natural join student where student.name=name); end$; call makul_belum('Williams')$;
12.
create procedure makul_not(in name varchar(50)) begin select name,course_id,title from instructor natural join course where (id) not in(select id from teaches); end$; call makul_not('Kim')$;
Page 6
KBD Procedure
13.
create procedure course_tawar(in year char(4)) begin select course_id,title from course where 1 < (select count(course_id) from section where section.year=year and course.course_id=section.course_id)group by course_id; end$; call course_tawar(2010)$;
14.
create procedure course_year(in year char(4)) begin select title,count(course_id) from teaches natural join course where teaches.year=year group by title; end$; call course_year(2010)$;
Page 7
KBD Procedure
15.
create procedure building_year(in building varchar(15), year char(4)) begin select building,year,count(course_id) from course natural join section where course.dept_name=dept_name and section.year=year group by dept_name,year; end$; call building_year('Painter',2010);
Page 8