Enumerated Status Values and Reference Tables

A small fixed status set can be constrained directly. A reference table can give allowed statuses additional data and an independent lifecycle.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace status metadata
  2. Separate status from transitions
  3. Ask whether statuses need descriptions and independent lifecycle
  4. Keep transition rules separate from permitted labels

Trace status metadata

Draft, published, and archived may have stable codes. If statuses also have human labels and configurable order, a row for each code can store that metadata. Exhaustive branches describe handling supported codes.

Separate status from transitions

Declaring published a valid value does not say that every row can immediately move there. Keep transition policy explicit when history matters.[1][2]

Ask whether statuses need descriptions and independent lifecycle

A fixed internal workflow can allow draft, published and withdrawn. If each status also needs a translated description, display order and retirement flag, a reference table can attach those facts to stable codes. See reference codes with human labels.

Status code: draft
Display label: Draft
Sort order: 10
A record can reference the stable code

Keep transition rules separate from permitted labels

A valid status value does not authorize switching to it from every other status. Test allowed and rejected transitions separately. Choose how readers interpret records using a retired code.

References

  1. PostgreSQL Global Development Group, Data Definition ↩
  2. PostgreSQL Global Development Group, SQL Language Tutorial ↩