Questions: Database Triggers and Automated Event Handling

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A database designer wants to ensure that whenever a new order is inserted, the order's total price is automatically rounded to two decimal places. Which trigger type is most appropriate?

AAFTER INSERT FOR EACH ROW — it runs after the data is stored, so you can correct it
BBEFORE INSERT FOR EACH ROW — it intercepts the data before writing and can modify NEW.total_price
CAFTER INSERT FOR EACH STATEMENT — it handles all rows at once for efficiency
DEither BEFORE or AFTER works identically for data modification
Question 2 Multiple Choice

A bulk UPDATE statement modifies 10,000 rows. How many times does a FOR EACH ROW trigger on that table execute, compared to a statement-level trigger?

ABoth execute exactly once, since it is one statement
BThe FOR EACH ROW trigger executes 10,000 times; the statement-level trigger executes once
CThe FOR EACH ROW trigger executes once; the statement-level trigger executes 10,000 times
DBoth execute 10,000 times for a bulk UPDATE
Question 3 True / False

An AFTER trigger can cause the data change that fired it to be rolled back.

TTrue
FFalse
Question 4 True / False

Because triggers fire automatically regardless of which application modifies the data, they are the best place to enforce most business logic in a database application.

TTrue
FFalse
Question 5 Short Answer

Explain the key difference between what a BEFORE trigger and an AFTER trigger can accomplish, and give an example of an appropriate use case for each.

Think about your answer, then reveal below.