Multiple choice technology databases

You have a database that contains several FOREIGN KEY and CHECK constraints. Users are having problems with data entry on the database because the data they are adding is constantly in violation of the CHECK constraints. Corporate policy regarding database design prevents you from modifying the current constraints, so you decide to implement your changes via a trigger. Which types of triggers would be best suited for this task?

  1. UPDATE, DELETE, and INSERT TRiggers

  2. Just UPDATE and INSERT triggers

  3. INSTEAD OF TRiggers

  4. Triggers cannot be used in this circumstance.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

INSTEAD OF triggers fire before the constraint check and can modify or cancel the operation. By using an INSTEAD OF trigger, you can intercept problematic INSERT/UPDATE operations that would violate CHECK constraints and either fix the data or prevent the violation from occurring. AFTER triggers (like UPDATE/INSERT) fire after constraints are checked, so they can't prevent constraint violations.