We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Database Fundamentals
Free preview: the first 2 parts of this 8-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Database Fundamentals
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
Two earlier lessons measured what a trigger costs. This one is about what a trigger does, because every finding here is a behaviour and not a number, and not one of them raises an error.

Every defect in this lesson is something the database did on purpose and said nothing about.

Nothing here is described from the documentation. Each result was produced and then queried.

Nothing in the table definition, the migration history or the application code suggests that ordering.
Two triggers where the second depends on the first is therefore a bug fixed by renaming one of them. That is why trigger names in older schemas so often start with a number, and why that prefix is load bearing.

The trigger was written to reject a negative amount, and RETURN NULL is how a BEFORE trigger says do not store this row.
RAISE EXCEPTION is the version that says something and RETURN NULL is the version that does not. A validation trigger that discards rows produces an application that writes data and reads back less than it wrote.