Recall & Review
beginner
What is a trigger in a database?
A trigger is a special kind of stored procedure that automatically runs when certain events happen in the database, like inserting, updating, or deleting data.
Click to reveal answer
beginner
Why do triggers help automate responses in a database?
Triggers automatically perform actions when data changes, so you don't have to write extra code to check and respond to those changes manually.
Click to reveal answer
beginner
When can a trigger be set to run?
A trigger can run before or after an insert, update, or delete operation on a table.
Click to reveal answer
beginner
Give a simple real-life example of a trigger's use.
For example, when a new order is added, a trigger can automatically update the stock quantity without needing a separate program to do it.
Click to reveal answer
intermediate
How do triggers improve data consistency?
Triggers ensure that related actions happen automatically and immediately, which helps keep data accurate and consistent without relying on manual steps.
Click to reveal answer
What event can a trigger NOT respond to?
✗ Incorrect
Triggers respond to data changes like insert, update, and delete, but not to select queries which only read data.
When does a BEFORE trigger run?
✗ Incorrect
A BEFORE trigger runs just before the data change happens, allowing you to check or modify data before it is saved.
Why use triggers instead of manual code for automation?
✗ Incorrect
Triggers automate responses by running automatically when data changes, so you don't need to write extra code.
Which of these is a benefit of using triggers?
✗ Incorrect
Triggers can automatically check and validate data when it changes, improving data quality.
What happens if a trigger fails during execution?
✗ Incorrect
If a trigger fails, the database often rolls back the data change to keep data consistent.
Explain in your own words why triggers help automate responses in a database.
Think about what happens when data changes and how triggers act without extra work.
You got /4 concepts.
Describe a simple example where a trigger can be useful in a real-life database.
Imagine a store updating stock when a sale happens.
You got /4 concepts.