I am working on limiting input in certain fields in my Postgres database, and I have a working solution using
ENUM like so:
CREATE TYPE label AS ENUM ('foo','bar');
However, I was browsing around and looking at alternative ways of doing this using:
- constraints (eg.
CHECK (type IN ('foo','bar')))
- triggers (slow, from what I've read)
- foreign keys
What are the advantages/disadvantages of using either of these methods, would any of these be more advisable? I am not necessarily asking which one is the 'best' method, only what kind of issues may arise from using these, ie. I know that using triggers might be quite slow compared to the other methods, but perhaps could deal with some more complex input conditions.