6. Bố cục luận văn
3.1.5. KNT danh sách lớp học phần sinh viên được phép đăng ký mv1
a) Mục đích:
- Lập danh sách lớp học phần sinh viên được phép đăng ký. b) Tạo bảng thể hiện KNT:
create table mv1(
masv character varying (12), malophp int,
mamh int,
tenmh character varying (30) );
c) Khởi tạo dữ liệu:
insert into mv1
select mv1b.masv, mv1a.malophp, mv1a.mamh,mv1a.tenmh from mv1a join mv1b on mv1a.mamh =mv1b.mamh;
d) Tạo các hàm và trigger:
* Theo chiến lược gia tăng đồng bộ:
create function mv1a_mv1_insert() returns trigger as 'qlsinhvien.dll', 'mv1a_mv1_insert' language c strict;
create trigger mv1a_mv1_insert after insert on mv1a for each row execute procedure mv1a_mv1_insert() ;
create function mv1a_mv1_delete() returns trigger as 'qlsinhvien.dll', 'mv1a_mv1_delete' language c strict;
create trigger mv1a_mv1_delete after delete on mv1a for each row execute procedure mv1a_mv1_delete();
create function mv1a_mv1_update() returns trigger as 'qlsinhvien.dll', 'mv1a_mv1_update' language c strict;
create trigger mv1a_mv1_update after update on mv1a for each row execute procedure mv1a_mv1_update();
create function mv1b_mv1_insert() returns trigger as 'qlsinhvien.dll', 'mv1b_mv1_insert' language c strict;
create trigger mv1b_mv1_insert after insert on mv1b for each row execute procedure mv1b_mv1_insert() ;
create function mv1b_mv1_delete() returns trigger as 'qlsinhvien.dll', 'mv1b_mv1_delete' language c strict;
create trigger mv1b_mv1_delete after delete on mv1b for each row execute procedure mv1b_mv1_delete();
create function mv1b_mv1_update() returns trigger as 'qlsinhvien.dll', 'mv1b_mv1_update' language c strict;
create trigger mv1b_mv1_update after update on mv1b for each row execute procedure mv1b_mv1_update();
* Theo chiến lược toàn phần đồng bộ:
create function mv1_all() returns trigger as 'qlsinhvien.dll', 'mv1_all' language c strict;
create trigger svmv1_all AFTER INSERT OR UPDATE OR DELETE on sinhvien execute procedure mv1_all() ;
create trigger lopmv1_all AFTER INSERT OR UPDATE OR DELETE on lop execute procedure mv1_all() ;
create trigger khoamv1_all AFTER INSERT OR UPDATE OR DELETE on khoa execute procedure mv1_all() ;
create trigger nganhmv1_all AFTER INSERT OR UPDATE OR DELETE on nganh execute procedure mv1_all() ;
create trigger chuongtrinhmv1_all AFTER INSERT OR UPDATE OR DELETE on chuongtrinh execute procedure mv1_all() ;
create trigger monhocmv1_all AFTER INSERT OR UPDATE OR DELETE on monhoc execute procedure mv1_all() ;
create trigger lophpmv1_all AFTER INSERT OR UPDATE OR DELETE on lophocphan execute procedure mv1_all() ;
create trigger hocmv1_all AFTER INSERT OR UPDATE OR DELETE on hoc execute procedure mv1_all() ;