Recall & Review
beginner
What is a database trigger?
A database trigger is a special procedure that automatically runs when certain events happen in the database, like inserting, updating, or deleting data.
Click to reveal answer
beginner
Why should triggers be kept simple and fast?
Because triggers run automatically during data changes, slow or complex triggers can delay the main operation and affect database performance.
Click to reveal answer
intermediate
Name one limitation of MySQL triggers.
MySQL allows only one trigger per table for each combination of timing (BEFORE/AFTER) and event (INSERT/UPDATE/DELETE), which limits splitting complex logic across multiple triggers.
Click to reveal answer
intermediate
What is a common best practice when using triggers to avoid unexpected behavior?
Avoid having triggers that cause other triggers to fire in a loop, which can cause infinite recursion and crash the database.
Click to reveal answer
beginner
How can you test a trigger safely before applying it in production?
Test triggers in a development or staging environment with sample data to ensure they work correctly and do not cause errors or performance issues.
Click to reveal answer
Which event can a MySQL trigger NOT respond to?
✗ Incorrect
Triggers in MySQL cannot be set to run on SELECT statements; they only respond to data changes like INSERT, UPDATE, or DELETE.
What happens if a trigger causes another trigger to fire repeatedly in MySQL?
✗ Incorrect
If triggers call each other repeatedly without stopping, it causes infinite recursion which can crash the database.
Which is a good practice when writing triggers?
✗ Incorrect
Keeping triggers simple and fast helps maintain good database performance and avoids delays.
Can MySQL triggers call stored procedures that modify data?
✗ Incorrect
Yes, MySQL triggers can call stored procedures that modify data, but this must be done carefully to avoid recursion issues.
Where should you test triggers before using them in production?
✗ Incorrect
Testing triggers in a development or staging environment helps catch errors and performance issues before affecting live data.
Explain the best practices to follow when creating triggers in MySQL.
Think about performance, safety, and testing.
You got /4 concepts.
Describe the main limitations of MySQL triggers.
Focus on what triggers cannot do and what risks they have.
You got /4 concepts.