Legitimate Uses of the Antipattern
As we discussed, ENUM may cause fewer problems if the set of values is unchanging. It’s still difficult to query the metadata for the set of values, but you can maintain a matching list of values in application code without getting out of sync.
ENUM is most likely to succeed when it would make no sense to alter the set of permitted values, such as when a column represents an either/or choice with two mutually exclusive values: LEFT/RIGHT, ACTIVE/IN-ACTIVE, ON/OFF, INTERNAL/EXTERNAL, and so on.
Check constraints can be used in many ways other than simply to implement an ENUM-like mechanism, such as checking that a time interval’s start is less than its end.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access