System Design
4. Database FundamentalsAnimated
Database Triggers
Code that runs automatically when data changes.
The idea
A trigger fires before or after an insert, update or delete to enforce rules or write audit rows.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- client
- gateway / proxy
- service
- cache
- data store
- queue / stream
Presentation tier: the browser shows the interface.
- step:
- 1/4
- at:
- Browser
1/9
The green dot is a request moving through the system.
Step by step
- 1Define a trigger on a table
- 2A write occurs
- 3The trigger fires
- 4Extra changes happen in the same transaction
Where it is used
Auditing and derived data.
Watch out for
Hidden side effects make debugging difficult.