31
DEPARTMENT OF COMPUTER ENGINEERING CO 3405: Database Management System REPORT ON: Library Management System GUIDED BY: SUBMITTED BY: Biswajit Debnath, AB-34015 Page 1

Library Management System- Final Report

Embed Size (px)

Citation preview

Page 1: Library Management System- Final Report

DEPARTMENT OF COMPUTER ENGINEERING

CO 3405: Database Management System REPORT ON:

Library Management System

GUIDED BY: SUBMITTED BY:

Mrs. Aruna Tiwari NAME: Biswajit Debnath& ROLL NO: ab34015

Ms. Preeti Choudhary CLASS: BE 3rd year

Biswajit Debnath, AB-34015 Page 1

Page 2: Library Management System- Final Report

CERTIFICATE

This is to certify that Mr. Biswajit Debnath(Roll No-AB 34015) studing in B.E. III year of this institute has completed his lab file of object oriented programming system.

Date:

Internal Examiner External Examiner

Case study of Library Management System

Biswajit Debnath, AB-34015 Page 2

Page 3: Library Management System- Final Report

Problem Specification:Library is a very essential part of any educational institute. And

every library should be managed well. Most of the libraries are manually managed. Managing manually is ok for small libraries. But managing manually of large libraries is very tough. Now-a-days every thing has become computerized. So, libraries should also be centrally managed by some software through computers, which simplifies managing of library. In this report I have tried to make such software which helps managing library.

Library management system:It is a software through which an institute can handle and manage

the library very well. Using this software, library will have some advantage then manual managing like:

1. It will make easy the searching of books.2. It take less time to process the book issue.3. It take less time to process the book issue.4. It can handle the late fee issue very easily. etc.

Essential parts of library management system:1. Administrator: He enters new books and manage the book in proper systematic

manner. He also creates login to the librarian to transact books for students from the library with this software.

2. Librarian: He deals with students and faculty members by providing them library card and issuing books. He also enters information of new students and faculties who applies for library accessing into the library database. He also updates student information after every year.

3. Student: Using unique library id they can issue books which are available in the library.

4. Faculty: Using their unique library id they can issue books which are available in the library.

5. Books: Once books are entered into the database of the library the can be issued by students and faculty members who have library id and library card.

Tasks done by the software:The following tasks are done by this software.

Biswajit Debnath, AB-34015 Page 3

Page 4: Library Management System- Final Report

1. Administraror will enter new books in the database. He can allow librarian to deal with students and faculties.

2. Librarian can enter the new student and faculty information in the database and give them library id and library card.

3. Librarian can issue books to the student and faculty who have library id.4. Once book is issued it must be returned between the return date.5. If book is returned after return date then late fee will be charged.6. One can search for a book which he needed.

For efficient working of the software the following should be taken care:-

1. Data redundancy and: Data should be in consistent in the system and redundancy should be reduced as less as possible.

2. Data integrity: The values stored in the database must satisfy certain types of consistency constraints which is applied to the database.

3. Atomicity problem: If a transaction is started it should completed properly. If any kind of interruption happen the transaction should be roll back into the initial condition.

4. Concurrent access anomalies: if a person is accessing some data from the database this data should not be accessed by other user until former user ends his tasks.

5. Security problem: Not every user of the database is allowed to change it.

Entity-Relationship data model analysis

Biswajit Debnath, AB-34015 Page 4

Page 5: Library Management System- Final Report

1. Entity sets and their attributes:a. Lib-employee:

i. Emp_name.ii. Emp_id.

iii. Password.iv. Emp_type.

b. Student: i. Stu_name.

ii. Enrollment_no.iii. Year.iv. Branch.v. Roll_no.

vi. Sem.vii. Lib_id.

viii. Address.ix. Category.x. Sex.

xi. Date_of_birth.xii. Phone_no.

c. Faculty: i. Fac_name.

ii. Fac_id.iii. Department.iv. Lib_id.v. Address.

vi. Sex.vii. Date_of_birth.

viii. Phone_no.d. Book:

i. Book_name.ii. Author.

iii. Publisher.iv. Isbn_no.v. Category.

vi. No_of_books.

2. Relationship sets and their descriptive attributes:a. Manage:

i. Action.

Biswajit Debnath, AB-34015 Page 5

Page 6: Library Management System- Final Report

ii. Action_date.iii. Manage_by.

Lib_employee and book entities will be related through this relationship set. Book will be totally participated in manage and cardinality will be one to many from lib_employee to book.

b. Stu_issue:i. Lib_id.

ii. Action.iii. Action_date.

Student and book entities will be related through this relationship set. Book will be totally participated in stu_issue and cardinality will be one to many from student to book.

c. Fac_issue:i. Lib_id.

ii. Action.iii. Action_date.

Faculty and book entities will be related through this relationship set. Book will be totally participated in fac_issue and cardinality will be one to many from faculty to book.

d. Work_on_stu:i. Employee.

ii. Action.iii. Action_date.

Student and lib_employee entities will be related through this relationship set. Book will be totally participated in work_on_stu and cardinality will be one to many from lib_employee to student.

e. Work_on_fac:iv. Employee.v. Action.

vi. Action_date.Faculty and lib_employee entities will be related through this relationship set. Book will

be totally participated in work_on_fac and cardinality will be one to many from lib_employee to faculty.

Transformation of ER-Diagram into Table

1. Lib_employee ( emp_name, emp_id, password, emp_type).

Biswajit Debnath, AB-34015 Page 6

Page 7: Library Management System- Final Report

2. Student ( stu_name, enrollment_no, year, branch, roll_no, sem, lib_id, address, phone_no, date_of_birth, sex, catagory ).

3. faculty ( fac_name, fac_id, department, lib_id, address, phone_no, date_of_birth, sex)4. book (book_name, author, isbn_no, publisher, catagory, no_of_books).5. manage ( emp_id, isbn_no, manage_by, action, action_date).6. stu_issue ( enrollment_no, lib_id, isbn_no, action, action_date).7. fac_issue ( fac_id, lib_id, isbn_no, action, action_date).8. work_on_stu ( enrollment_no, emp_id, employee, action, action_date).9. work_on_fac ( fac_id, emp_id, employee, action, action_date).

Modules and algorithms

1. Login and loglut:Algorithm:

A. Employee of library enters their login id and password.B. This software checks if the entered valid entries.C. If their login id and password is correct then they are logged inD. Otherwise a message is shown as there login id or password is not correct.E. If they are already logged in then ‘already logged’ in message is shown.F. And after work the can logout from the database.

2. New student of faculty entry:Algorithms:

A. Student and entries are done by librarian.B. Librarian enters valid entries into the database.C. This software checks some privileges.D. If all checks are ok then their data is inserted into the database.E. Else some error notes are shown according to the checks.

3. Book entry:Algorithms:

A. Books can be entered by administrator.B. When new books are available then admin enters their entries into the data base.C. Once books are in the database the can be used by students and faculties.

4. Book search:Algorithms:

A. A book is searched by its name and authors name.B. If book is available then available note is shown.C. If not available then not available message is shown.

5. Book issue and return:A. A student or faculty applies for issue a book.B. This system checks if his library id is valid or not.

Biswajit Debnath, AB-34015 Page 7

Page 8: Library Management System- Final Report

C. If valid then checks if applied book is available or not.D. If book is available then this book is issued.E. If this book is already issued one time then he cannot issue the same book more

then one time.F. If book is not available then message is shown.G. When book is issued it is omitted from database.H. When book is returned it is entered into the database.I. Late fee is calculated if returned after return date.

CodingCreating tables:

1. create table lib_employee

Biswajit Debnath, AB-34015 Page 8

Page 9: Library Management System- Final Report

( emp_name varchar2(20) not null, emp_id varchar2(6) primary key,check(emp_id like 'AD%' or emp_id like 'LB%'), password varchar2(8) not null, emp_type varchar2(10) not null, check (emp_type in('Admin','Librarian')));

2. create table student( stu_name varchar2(20) not null, enrollment_no varchar2(12) primary key, check(enrollment_no like '0801CS%' or enrollment_no like '0801EC%' or enrollment_no like '0801ME%' or enrollment_no like '0801IT%' or enrollment_no like '0801CV%' or enrollment_no like '0801IP%' or enrollment_no like '0801EE%'), year number(1) not null, check(year in(1,2,3,4)), branch varchar2(10) not null, check(branch in('CSE','ETC','MECH','IT','CIVIL','IP','ELECTRICAL')), roll_no number(3) not null, unique( year, branch, roll_no), sem char(1) not null, check (sem in('A','B')), lib_id varchar2(6) not null, check(lib_id like 'CS1%' or lib_id like 'CS2%' or lib_id like 'CS3%' or lib_id like 'CS4%' or lib_id like 'EC1%' or lib_id like 'EC2%' or lib_id like 'EC3%' or lib_id like 'EC4%' or lib_id like 'ME1%' or lib_id like 'ME2%' or lib_id like 'ME3%' or lib_id like 'ME4%' or lib_id like 'IT1%' or lib_id like 'IT2%' or lib_id like 'IT3%' or lib_id like 'IT4%' or lib_id like 'CV1%' or lib_id like 'CV2%' or lib_id like 'CV3%' or lib_id like 'CV4%' or lib_id like 'IP1%' or lib_id like 'IP2%' or lib_id like 'IP3%' or lib_id like 'IP4%' or lib_id like 'EE1%' or lib_id like 'EE2%' or lib_id like 'EE3%' or lib_id like 'EE4%'),unique(lib_id), address varchar2(30) not null, phone_no number(10), date_of_birth date not null, sex char(1) not null, check(sex in('M','F')), catagory varchar2(3) not null, check(catagory in('ST','SC','OBC','GEN')));

3. create table faculty( fac_name varchar2(20) not null,

Biswajit Debnath, AB-34015 Page 9

Page 10: Library Management System- Final Report

fac_id varchar2(4) primary key, check(fac_id like 'CS%' or fac_id like 'EC%' or fac_id like 'IT%' or fac_id like 'ME%' or fac_id like 'IP%' or fac_id like 'CV%' or fac_id like 'EE%'), department varchar2(10) not null, check(department in('CSE','E&TC','MECH','IT','CIVIL','IP','ELECTRICAL')), lib_id varchar2(5) not null,check(lib_id like 'CSL%' or lib_id like 'ECL%' or lib_id like 'ITL%' or lib_id like 'MEL%' or lib_id like 'IPL%' or lib_id like 'CVL%' or lib_id like 'EEL%'),unique (lib_id), address varchar2(30) not null, phone_no number(10), date_of_birth date not null, sex char(1) not null, check(sex in('M','F')));

4. create table book( book_name varchar2(50) not null, author varchar2(20) not null, isbn_no number(10) primary key, publisher varchar2(30) not null, catagory varchar2(20) not null,check(catagory in('computer','comunication','civil','electrical','mechanical','mathematics')), no_of_books number(2));

5. create table manage( emp_id varchar2(6),foreign key(emp_id) references lib_employee(emp_id), isbn_no number(10),foreign key(isbn_no) references book(isbn_no), manage_by varchar2(10) not null,check(manage_by='Admin'), action varchar2(8) not null, check(action in('entry','update','delete')), action_date date not null);

6. create table stu_issue( enrollment_no varchar2(12),foreign key(enrollment_no) references student(enrollment_no),

Biswajit Debnath, AB-34015 Page 10

Page 11: Library Management System- Final Report

lib_id varchar2(6), foreign key(lib_id) references student(lib_id), isbn_no number(10), foreign key(isbn_no) references book(isbn_no), action varchar2(8) not null, check (action in('issue','return')), action_date date not null);

7. create table fac_issue( fac_id varchar2(4),foreign key(fac_id) references faculty(fac_id), lib_id varchar2(6), foreign key(lib_id) references faculty(lib_id), isbn_no number(10), foreign key(isbn_no) references book(isbn_no), action varchar2(8) not null, check (action in('issue','return')), action_date date not null);

8. create table work_on_stu( enrollment_no varchar2(12) references student, emp_id varchar2(6) references lib_employee, employee varchar2(9)not null, check(employee='Librarian'), action varchar2(6)not null, check(action in('entry','update')), action_date date not null);

9. create table work_on_fac( fac_id varchar2(4) references faculty, emp_id varchar2(6) references lib_employee, employee varchar2(9)not null, check(employee='Librarian'), action varchar2(6)not null, check(action in('entry','update')), action_date date not null);

10. create table logged_on(login_name varchar2(10) primary key);11. create table issue_track(lib_id varchar2(6) primary key, book_to_return number(2));

Procedures:

1. Login:create or replace procedure login(login in varchar2, pass in varchar2) isconstraint_violated exception;

Biswajit Debnath, AB-34015 Page 11

Page 12: Library Management System- Final Report

pragma exception_init(constraint_violated,-00001);cursor c1 is select login_name from logged_on where login_name = login;cursor log_csr is select emp_id, password from lib_employee where emp_id= login;vlogin_id lib_employee.emp_id%type;vpassword lib_employee.password%type;beginfor i in c1loopif c1%isopen thenraise constraint_violated; end if;end loop;open log_csr; loopfetch log_csr into vlogin_id,vpassword;exit when log_csr%notfound;if vlogin_id=login and vpassword=pass thendbms_output.put_line('login successful');insert into logged_on values(login);elsedbms_output.put_line('invalid login or password');end if;end loop;close log_csr;exceptionwhen constraint_violated thendbms_output.put_line('you have already logged in.');end;

2. Logout:create or replace procedure logout(login in varchar2)iscursor c is select login_name from logged_on where login_name = login;beginfor i in cloop

Biswajit Debnath, AB-34015 Page 12

Page 13: Library Management System- Final Report

if c%isopen thendelete from logged_on where login_name=login;dbms_output.put_line('you are successfully logged out');end if;end loop;end;

3. Insert bookcreate or replace procedure insert_book(name in varchar2, author in varchar2, isbn in number, pub in varchar2, cat in varchar2, no in number)ise1 exception;pragma exception_init(e1,-00001);e2 exception;pragma exception_init(e2,-02290);var1 number(2);beginif isbn like '__________' then /*for 10 digit no*/insert into book values(name, author, isbn, pub, cat, no);dbms_output.put_line('book is successfully inserted');elsedbms_output.put_line('isbn_no is not valid');end if;exceptionwhen e1 thenselect no_of_books into var1 from book where isbn_no=isbn;var1:=var1+no;update book set no_of_books=var1 where isbn_no=isbn;dbms_output.put_line('book is successfully inserted');when e2 thendbms_output.put_line('please enter valid entries');end;

4. Student entry:create or replace procedure student_entry(name in varchar2, enroll in varchar2, year in number, branch in varchar2, roll in number, sem in char, lib in varchar2, add in varchar2, phone in number, dob in date, sex in char, cat in varchar2)ise1 exception;pragma exception_init(e1,-00001);e2 exception;

Biswajit Debnath, AB-34015 Page 13

Page 14: Library Management System- Final Report

pragma exception_init(e2,-02290);e3 exception;pragma exception_init(e3,-01400);begininsert into student values(name, enroll, year, branch, roll, sem, lib, add, phone, dob, sex, cat);dbms_output.put_line('entry successfull');exceptionwhen e1 thendbms_output.put_line('this entry have invalid enrollment no or lib_id or roll no or already exists. please chack and enter valid entries');when e2 thendbms_output.put_line('you may check your entries, they might be entered wrong.');when e3 thendbms_output.put_line('null values are not allowed here');end;

5. Faculty entrycreate or replace procedure faculty_entry(name in varchar2, id in varchar2, department in varchar2, lib in varchar2, add in varchar2, phone in number, dob in date, sex in char)ise1 exception;pragma exception_init(e1,-00001);e2 exception;pragma exception_init(e2,-02290);e3 exception;pragma exception_init(e3,-01400);begininsert into faculty values(name, id, department, lib, add, phone, dob, sex);dbms_output.put_line('entry successfull');exceptionwhen e1 thendbms_output.put_line('this entry have invalid faculty id or lib_id or already exists. please chack and enter valid entries');when e2 thendbms_output.put_line('you may check your entries, they might be entered wrong.');when e3 thendbms_output.put_line('null values are not allowed here');end;

6. Search bookcreate or replace procedure book_search (name in varchar2, authr in varchar2) isvar1 number(2):=0;

Biswajit Debnath, AB-34015 Page 14

Page 15: Library Management System- Final Report

beginselect no_of_books into var1 from book where book_name = name and author= authr;if var1>0 thendbms_output.put_line('available');elsedbms_output.put_line('not available');end if;exceptionwhen no_data_found thendbms_output.put_line('not available');end;

7. Student book issuecreate or replace procedure stu_book_issue (lib in varchar2, name in varchar2, authr in varchar2) iscursor c is select lib_id from student;var1 number(2):=0;var2 varchar2(12);var3 varchar2(10);var4 varchar2(6);var5 number(1):=0;var6 number(1):=0;var7 number(10);e1 exception;beginselect count(lib_id) into var5 from student where lib_id=lib;if var5=0 thenraise e1;elseselect isbn_no into var7 from book where book_name=name and author=authr;select count(isbn_no) into var6 from stu_issue where isbn_no=var7 and lib_id=lib;if var6 > 0 thendbms_output.put_line('you cannot issue the same book more then one time');elseopen c;loopfetch c into var4 ;exit when c%notfound;if var4=lib thenselect no_of_books into var1 from book where book_name = name and author= authr;if var1>0 then

Biswajit Debnath, AB-34015 Page 15

Page 16: Library Management System- Final Report

select enrollment_no into var2 from student where lib_id=lib;select isbn_no into var3 from book where book_name=name and author= authr;insert into stu_issue values(var2, lib, var3, 'issue', sysdate);update book set no_of_books=no_of_books-1 where isbn_no=var3;dbms_output.put_line('book issued successfully');elsedbms_output.put_line('this book is not available');end if;end if;end loop;close c;end if;end if;exceptionwhen e1 thendbms_output.put_line('your library id is not valid. please enter a valid id');when no_data_found thendbms_output.put_line('this book is not available1');end;

8. Faculty book issuecreate or replace procedure fac_book_issue (lib in varchar2, name in varchar2, authr in varchar2) iscursor c is select lib_id from faculty;var1 number(2):=0;var2 varchar2(4);var3 varchar2(10);var4 varchar2(6);var5 number(1):=0;var6 number(1):=0;var7 number(10);e1 exception;beginselect count(lib_id) into var5 from faculty where lib_id=lib;if var5=0 thenraise e1;elseselect isbn_no into var7 from book where book_name=name and author=authr;select count(isbn_no) into var6 from fac_issue where isbn_no=var7 and lib_id=lib;if var6 > 0 thendbms_output.put_line('you cannot issue the same book more then one time');

Biswajit Debnath, AB-34015 Page 16

Page 17: Library Management System- Final Report

elseopen c;loopfetch c into var4 ;exit when c%notfound;if var4=lib thenselect no_of_books into var1 from book where book_name = name and author= authr;if var1>0 thenselect fac_id into var2 from faculty where lib_id=lib;select isbn_no into var3 from book where book_name=name and author= authr;insert into fac_issue values(var2, lib, var3, 'issue', sysdate);update book set no_of_books=no_of_books-1 where isbn_no=var3;dbms_output.put_line('book issued successfully');elsedbms_output.put_line('this book is not available');end if;end if;end loop;close c;end if;end if;exceptionwhen e1 thendbms_output.put_line('your library id is not valid. please enter a valid id');when no_data_found thendbms_output.put_line('this book is not available'); end;

9. Student book returncreate or replace procedure stu_book_return (lib in varchar2, isbn in varchar2) isvar1 number(1):=0;var2 varchar2(12); var3 number(10);var4 number(2);var5 date;var6 number(2):=0;var7 number(1):=0;var8 number(1):=0;e1 exception;

Biswajit Debnath, AB-34015 Page 17

Page 18: Library Management System- Final Report

begin select count(lib_id) into var7 from student where lib_id=lib;if var7=0 thenraise e1;elseselect count(isbn_no) into var8 from stu_issue where isbn_no=isbn;select count(lib_id) into var1 from issue_track where lib_id=lib;if var1!=0 and var8!=0 thenselect action_date into var5 from stu_issue where lib_id=lib and isbn_no=isbn;var6:=var5-sysdate;select enrollment_no into var2 from student where lib_id=lib;select isbn_no into var3 from book where isbn_no=isbn;insert into stu_issue values(var2, lib, var3, 'return', sysdate);update book set no_of_books=no_of_books+1 where isbn_no=var3;dbms_output.put_line('book returned');delete from stu_issue where lib_id=lib and isbn_no=isbn;if var6>30 thendbms_output.put_line('you have charged Rs '||var6||' for late fees.');end if;select book_to_return into var4 from issue_track where lib_id=lib;if var4>0 thendbms_output.put_line('you have '||var4||' books to return.');end if;elsedbms_output.put_line('you have not issued this book from here.');end if;end if;exceptionwhen e1 thendbms_output.put_line('please enter valid library id.');when no_data_found thendbms_output.put_line('');end;

10. Faculty book returncreate or replace procedure fac_book_return (lib in varchar2, isbn in varchar2) isvar1 number(1):=0;var2 varchar2(12); var3 number(10);var4 number(2);var5 date;

Biswajit Debnath, AB-34015 Page 18

Page 19: Library Management System- Final Report

var6 number(2):=0;var7 number(1):=0;var8 number(1):=0;e1 exception;begin select count(lib_id) into var7 from faculty where lib_id=lib;if var7=0 thenraise e1;elseselect count(isbn_no) into var8 from fac_issue where isbn_no=isbn;select count(lib_id) into var1 from issue_track where lib_id=lib;if var1!=0 and var8!=0 thenselect max(action_date) into var5 from fac_issue where lib_id=lib and isbn_no=isbn;var6:=var5-sysdate;select fac_id into var2 from faculty where lib_id=lib;select isbn_no into var3 from book where isbn_no=isbn;insert into fac_issue values(var2, lib, var3, 'return', sysdate);update book set no_of_books=no_of_books+1 where isbn_no=var3;dbms_output.put_line('book returned');delete from fac_issue where lib_id=lib and isbn_no=isbn;if var6>30 thendbms_output.put_line('you have charged Rs '||var6||' for late fees.');end if;select book_to_return into var4 from issue_track where lib_id=lib;if var4>0 thendbms_output.put_line('you have '||var4||' books to return.');end if;elsedbms_output.put_line('you have not issued this book from here.');end if;end if;exceptionwhen e1 thendbms_output.put_line('please enter valid library id.');when no_data_found thendbms_output.put_line('');end;

Biswajit Debnath, AB-34015 Page 19

Page 20: Library Management System- Final Report

Triggers:

1. Manage bookcreate or replace trigger manage_book after insert on book for each rowdeclarevar2 varchar2(8);beginselect emp_id into var2 from lib_employee where emp_type='Admin'; insert into manage values (var2,:new.isbn_no,'Admin','entry',sysdate);end;

2. Keep track for studentcreate or replace trigger keep_track after insert on stu_issue for each rowdeclare

Biswajit Debnath, AB-34015 Page 20

Page 21: Library Management System- Final Report

var1 number(2);e1 exception;pragma exception_init(e1,-00001);begininsert into issue_track values(:new.lib_id,1);exceptionwhen e1 thenif :new.action ='issue' thenselect book_to_return into var1 from issue_track where lib_id=:new.lib_id;var1:=var1+1;update issue_track set book_to_return=var1 where lib_id=:new.lib_id;elseselect book_to_return into var1 from issue_track where lib_id=:new.lib_id;var1:=var1-1;if var1>0 thenupdate issue_track set book_to_return=var1 where lib_id=:new.lib_id;elsedelete from issue_track where lib_id=:new.lib_id;end if;end if;end;

3. Keep track for facultycreate or replace trigger keep_track1 after insert on fac_issue for each rowdeclarevar1 number(2);e1 exception;pragma exception_init(e1,-00001);begininsert into issue_track values(:new.lib_id,1);exceptionwhen e1 thenif :new.action ='issue' thenselect book_to_return into var1 from issue_track where lib_id=:new.lib_id;var1:=var1+1;update issue_track set book_to_return=var1 where lib_id=:new.lib_id;else

Biswajit Debnath, AB-34015 Page 21

Page 22: Library Management System- Final Report

select book_to_return into var1 from issue_track where lib_id=:new.lib_id;var1:=var1-1;if var1>0 thenupdate issue_track set book_to_return=var1 where lib_id=:new.lib_id;elsedelete from issue_track where lib_id=:new.lib_id;end if;end if;end;

4. Student employeecreate or replace trigger stu_emp after insert or update on student for each rowdeclarevar1 varchar2(6);beginif inserting thenselect emp_id into var1 from lib_employee where emp_type='Librarian';insert into work_on_stu values(:new.enrollment_no,var1,'Librarian','entry',sysdate);elseselect emp_id into var1 from lib_employee where emp_type='Librarian';insert into work_on_stu values(:old.enrollment_no,var1,'Librarian','update',sysdate);end if;end;

5. Faculty employeecreate or replace trigger fac_emp after insert or update on faculty for each rowdeclarevar1 varchar2(6);beginif inserting thenselect emp_id into var1 from lib_employee where emp_type='Librarian';insert into work_on_fac values(:new.fac_id,var1,'Librarian','entry',sysdate);elseselect emp_id into var1 from lib_employee where emp_type='Librarian';insert into work_on_fac values(:old.fac_id,var1,'Librarian','update',sysdate);end if;end;

Biswajit Debnath, AB-34015 Page 22