Skip to content
StackDecode
System Design
4. Database FundamentalsAnimated

Stored Procedures

Code stored and executed inside the database.

The idea

Procedures run close to the data, reducing round trips and centralising logic.

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 the procedure
  2. 2Application calls it with parameters
  3. 3The database runs the logic
  4. 4Results return

Where it is used

Batch operations.

Watch out for

Business logic hidden in the database is hard to test and version.

Related