When an employee is deleted from the COMPANY database, triggers are used to:
1) Delete any related PROJECT tuples and DEPENDENT tuples for that employee.
2) Set the Mgr_ssn field to NULL for any department managed by that employee.
3) Set the Super_ssn field to NULL for any employees supervised by that employee.
The trigger code provided deletes the related rows from other tables and updates supervisor fields to NULL as needed when an employee is deleted.
When an employee is deleted from the COMPANY database, triggers are used to:
1) Delete any related PROJECT tuples and DEPENDENT tuples for that employee.
2) Set the Mgr_ssn field to NULL for any department managed by that employee.
3) Set the Super_ssn field to NULL for any employees supervised by that employee.
The trigger code provided deletes the related rows from other tables and updates supervisor fields to NULL as needed when an employee is deleted.
When an employee is deleted from the COMPANY database, triggers are used to:
1) Delete any related PROJECT tuples and DEPENDENT tuples for that employee.
2) Set the Mgr_ssn field to NULL for any department managed by that employee.
3) Set the Super_ssn field to NULL for any employees supervised by that employee.
The trigger code provided deletes the related rows from other tables and updates supervisor fields to NULL as needed when an employee is deleted.
Use APEX for the lab activities and company schema
Consider the COMPANY database provided in the previous assignment. Using the syntax of Oracle triggers, create triggers to do the following:
Whenever an employee is deleted, delete the PROJECT tuples and DEPENDENT
tuples related to that employee, and if the employee manages a department or supervises employees, set the Mgr_ssn for that department to NULL and set the Super_ssn for those employees to NULL. You are required to provide the trigger code, SQL statements to test the triggers and screenshots of the database state of affected rows before and after executing trigger test statements and an explanation of your logic.
Solution:
CREATE TRIGGER DELETE_IN_CASCADE
AFTER DELETE ON EMPLOYEE FOR EACH ROW BEGIN DELETE FROM WORKS_ON WHERE ESSN = OLD.SSN; DELETE FROM DEPENDENT WHERE ESSN = OLD.SSN; UPDATE EMPLOYE SET SUPERSSN = ‘null’ WHERE SUPERSSN = OLD.SSN; END;