Implementing State Machines in PostgreSQL

databases