A finite-state machine models a record as occupying one value from a defined set and changing values through specified transitions. In a schema, an enum can make that lifecycle explicit: each transition represents a business rule that application code must enforce. section 7.1
Read a finite-state machine in a schema by asking:
- Which states are explicitly allowed? A booking status may be ACCEPTED, PENDING, REJECTED, CANCELLED, or AWAITING_HOST. section 7.1
- Which transitions matter to the business? Moving from PENDING to ACCEPTED is not merely a data update; it expresses a rule the application must enforce. section 7.1
- What surrounding fields explain the lifecycle? A cancellation-reason field signals that cancellations are important enough to track. section 7.0
Booking workflow
A booking begins as PENDING, may become ACCEPTED, and can also be REJECTED or CANCELLED. The enum defines the permitted vocabulary; application behavior must define and protect the valid paths between those states. section 7.1
Listing 7.1 A minimal_booking_schema defining the tables and columns for a simple booking system in SQL.
CREATE TABLE booking ( id SERIAL PRIMARY KEY, event_type_id INT NOT NULL REFERENCES event_type(id), start_time TIMESTAMPTZ NOT NULL, attendee_email TEXT NOT NULL, status booking_status NOT NULL DEFAULT 'pending', metadata JSONB ); CREATE INDEX ON booking (start_time, event_type_id); CREATE UNIQUE INDEX ON booking (attendee_email);
Inspect the status column in a minimal SQL booking schema to see a state-machine value embedded alongside required fields, relationships, and indexes. section 7.1












