Difficulty: Easy
Correct Answer: They have an event, condition, and action.
Explanation:
Introduction:
Triggers are server-side programs that automatically execute in response to data changes or certain database events. Understanding their structure helps you design reliable integrity checks, auditing, and automated transformations at the database layer rather than in application code only.
Given Data / Assumptions:
Concept / Approach:
The classic ECA rule defines a trigger: Event (what change or operation causes the trigger to fire), Condition (optional predicate that must be true), and Action (the statements executed when the condition holds). Triggers are defined using SQL DDL and are database-resident, firing regardless of which application issues the triggering DML, unless disabled or restricted by conditions.
Step-by-Step Solution:
Identify the event such as INSERT, UPDATE, or DELETE on a specific table or view.Optionally specify a WHEN condition to filter the cases.Provide the action body to enforce rules, log changes, or transform data.Deploy using SQL DDL so the trigger fires automatically for qualifying operations.
Verification / Alternative check:
Database documentation shows trigger definitions in SQL and illustrates ECA behavior across engines like Oracle, SQL Server, and PostgreSQL (with procedural language bodies as applicable).
Why Other Options Are Wrong:
Common Pitfalls:
Creating trigger chains that are hard to reason about, leading to unintended cascades or performance issues. Use clear conditions and minimal side effects.
Final Answer:
They have an event, condition, and action.
Discussion & Comments