Question

    Which of the following is true about triggers in a

    relational database?
    A Triggers can be manually executed by database administrators Correct Answer Incorrect Answer
    B Triggers are stored procedures that automatically execute in response to specific events Correct Answer Incorrect Answer
    C Triggers replace indexes for optimizing queries. Correct Answer Incorrect Answer
    D Triggers are only used for logging data changes Correct Answer Incorrect Answer
    E Triggers can only be defined for INSERT operations. Correct Answer Incorrect Answer

    Solution

    Triggers are database objects that automatically execute predefined actions in response to specific events, such as INSERT, UPDATE, or DELETE operations. They are used to enforce complex business rules, maintain audit trails, or synchronize tables. For instance, a trigger can automatically log changes to a table in an audit table whenever a record is updated. Triggers are associated with a table or a view and fire without manual intervention, making them ideal for automation. While powerful, they should be used judiciously to avoid performance bottlenecks in high-transaction environments. Why Other Options Are Incorrect :

    1. Triggers can be manually executed by database administrators : Triggers are event-driven and cannot be executed manually.
    2. Triggers replace indexes for optimizing queries : Indexes are designed to optimize query performance, while triggers are for automating responses to events.
    3. Triggers are only used for logging data changes : While logging is a common use case, triggers have broader applications like enforcing business rules.
    4. Triggers can only be defined for INSERT operations : Triggers can be defined for INSERT, UPDATE, DELETE, or even complex conditions.

    Practice Next