980. Audit employee salary changes — trigger case 3

DBMS Published Updated 0 Views Verified
Implement the database trigger for this integrity/audit requirement. Consider NULL-safe comparisons and transaction behavior.
Looking for the latest Sarkari Result 2026 updates? Check the latest government exam results, merit lists and result updates on Sarkari Resultess.
Sarkari Resultess
Questions & Answers

Answer & Explanation

4 Answers
Verified Correct Answer

Option A

DELIMITER // CREATE TRIGGER trg_employee_salary_audit AFTER UPDATE ON employees FOR EACH ROW BEGIN IF OLD.salary <> NEW.salary THEN INSERT INTO employee_salary_audit(employee_id,old_salary,new_salary,changed_at) VALUES(NEW.id,OLD.salary,NEW.salary,NOW()); END IF; END // DELIMITER ;
Additional Explanation
Correct implementation. Prefer parameterized queries in application code, validate affected rows for UPDATE/DELETE, and use transactions for related writes.
Sarkari Resultess
Editorial Answer 1
Verified

Option B

Use a trigger that recursively updates the same table without safeguards.
Additional Explanation
This option is incorrect for the stated requirement.
Sarkari Resultess
Editorial Answer 2
Verified

Option C

Use a foreign key for an audit event that has no parent key.
Additional Explanation
This option is incorrect for the stated requirement.
Sarkari Resultess
Editorial Answer 3
Verified

Option D

Use a SELECT-only query and do not enforce the rule.
Additional Explanation
This option is incorrect for the stated requirement.
Sarkari Resultess
Editorial Answer 4