9.3. State Transition Tables

When most newbies think of constraints, they know only static column constraints, such as NOT NULL, DEFAULT, and CHECK () clauses. A little bit later, they will learn about simple declarative referential integrity (DRI) constraints. That means simple PRIMARY KEY and REFERENCES clauses with some simple actions to bring the database to a state consistent with business rules.

The bad news is that there are not enough SQL constructs for all business rules. A transition constraint says that an entity can be updated only in certain ways. These constraints are often modeled as a state transition diagram. There is an initial state, flow lines that show what the next legal state(s) are, and one or more termination states. ...

Get Joe Celko's Thinking in Sets: Auxiliary, Temporal, and Virtual Tables in SQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.