On Wed, 3 Jul 2002, Alvaro Herrera wrote:
> Bruce Momjian dijo:
>
> > Sure, use CHECK constraints on the column. That is the ANSI standard
> > way.
> >
> > gender CHAR(1) CHECK (gender IN ('M','F')),
>
> That's the solution for the ENUM MySQL datatype, but the SET datatype
> allows one to have multiple values in the column (or that's what I
> understood in the original message).
>
> In PostgreSQL, you could use an array to store multiple values. I don't
> know if one could set up a CHECK constraint so that every element in a
> varchar array is checked against a predefined set. Maybe it can be done
> at insertion time using a trigger?
Should work find if you've got a function that does the check. Using
contrib/array you could do the ugly check (col *='M' or col *='F')
which at least seems to work on current sources. You could do something
with regexs or build another function that checks a list of values.
However, that doesn't prevent you from having duplicates (I don't know how
MySQL's set works).
Or a details table and options table with the appropriate foreign keys.