Using a foreign key in a lookup table is the approach I use. In fact, I use this even when I use a database that supports ENUM (e.g. MySQL).
For simplicity, I can skip the ubiquitous " id " for the lookup table and simply use the actual value that I need in my main table as the primary key of the lookup table. This way you do not need to make a connection to get the value.
CREATE TABLE BugStatus ( status VARCHAR(20) PRIMARY KEY ); INSERT INTO BugStatus (status) VALUES ('NEW'), ('OPEN'), ('FIXED'); CREATE TABLE Bugs ( bug_id SERIAL PRIMARY KEY, summary VARCHAR(80), ... status VARCHAR(20) NOT NULL DEFAULT 'NEW', FOREIGN KEY (status) REFERENCES BugStatus(status) );
It's clear that storing rows takes up more space than the MySQL ENUM implementation, but if the table doesn't have millions of rows, that hardly matters.
Other advantages of the lookup table are that you can add or remove a value from the list with a simple INSERT or DELETE , while with ENUM you need to use ALTER TABLE to override the list.
Also try querying the current list of valid values ββin ENUM , for example, to populate a collection in your user interface. This is a serious annoyance! Using the lookup table is easy: SELECT status from BugStatus .
You can also add other attribute tables to the lookup table if you need to (for example, mark options that are available only to administrators). In ENUM you cannot comment on posts; they are just simple meanings.
Another option, besides the lookup table, would be to use CHECK restrictions (assuming the database supports them - MySQL does not work):
CREATE TABLE Bugs ( bug_id SERIAL PRIMARY KEY, summary VARCHAR(80), ... status VARCHAR(20) NOT NULL CHECK (status IN ('NEW', 'OPEN', 'FIXED')) );
But this use of the CHECK constraint has the same drawbacks as ENUM : it is difficult to change the list of values ββwithout ALTER TABLE , it is difficult to request a list of valid values, it is difficult to comment on the values.
PS: the equality comparison operator in SQL is single = . Double == doesn't make sense in SQL.