Finite state machine
Definition
A finite state machine defines a finite set of states, the events that trigger transitions, and which transitions are allowed from each state; any other transition is rejected.
In practice
Modelling workflows such as trips, orders or payments as state machines makes illegal states unrepresentable: a trip cannot be COMPLETED before it was IN_PROGRESS. Implementing each transition as a conditional write ("set MATCHED if currently REQUESTED") makes concurrent actors race safely: exactly one wins.
Transitions should be idempotent so retries are harmless, and each one can emit an event for downstream systems. Status columns updated with plain UPDATE ... SET status = ? lose those guarantees. Too many states or transitions become hard to reason about; split into nested or separate machines when that happens.
Example
Two matchers try to assign trip t-55; UPDATE trips SET state = 'MATCHED', driver = 42 WHERE id = 't-55' AND state = 'REQUESTED' updates one row for the first and zero for the second.