Skip to content
StackDecode
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.

BrowserApp serverDatabase
  • 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

  1. 1Define a trigger on a table
  2. 2A write occurs
  3. 3The trigger fires
  4. 4Extra changes happen in the same transaction

Where it is used

Auditing and derived data.

Watch out for

Hidden side effects make debugging difficult.

Related