Database triggers — evaluate the classification:\n“Three types of triggers are BEFORE, AFTER, and EXCEPTION.”\nState whether this statement is correct or incorrect, considering common SQL implementations and standard terminology (including INSTEAD OF for views).

Difficulty: Easy

Correct Answer: Incorrect

Explanation:


Introduction / Context:
Triggers are server-side routines that fire in response to data changes. Understanding their types and timing is essential for data integrity, auditing, and automation. The prompt suggests that the three types are BEFORE, AFTER, and EXCEPTION. This question checks whether that classification aligns with standard and widely used vendor terminology.



Given Data / Assumptions:

  • We compare common relational systems: Oracle, PostgreSQL, SQL Server, MySQL/MariaDB, etc.
  • We consider the canonical timing categories for DML triggers.
  • We acknowledge vendor-specific features such as INSTEAD OF for view updates.


Concept / Approach:
Standard terminology distinguishes triggers by timing relative to the triggering DML event: BEFORE and AFTER. Many vendors additionally support INSTEAD OF triggers (especially for updatable views), which replace the action rather than firing before or after it. “EXCEPTION” is not a standard timing type for triggers; exception handling is usually done within procedural code blocks, not as a trigger category. Thus the proposed trio is inaccurate.



Step-by-Step Solution:

List accepted types: BEFORE, AFTER, and often INSTEAD OF.Evaluate “EXCEPTION”: not a timing category; it is error/exception handling logic.Therefore, the claim’s classification is incorrect.Conclude that the correct set is BEFORE/AFTER (and possibly INSTEAD OF), not EXCEPTION.


Verification / Alternative check:
Review vendor docs: you find BEFORE/AFTER universally; EXCEPTION does not appear as a trigger kind. Some RDBMS provide statement-level versus row-level options, but those are orthogonal to timing types.



Why Other Options Are Wrong:

  • “Correct” conflicts with established nomenclature.
  • “Depends on isolation level” confuses concurrency with trigger timing.
  • “Mainframe dialects” and “procedural languages” are red herrings regarding SQL triggers.


Common Pitfalls:
Mixing exception blocks with trigger timing; forgetting INSTEAD OF triggers for view updates; assuming vendor-specific features are universal.



Final Answer:
Incorrect

More Questions from SQL for Database Construction

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion