I'm using Postgres and I have a table with a few columns of type boolean. c1,c2,c3,c4 are the columns (BOOLEAN).
In my model I must have one of them and only one set to true. The other three must be false.
I have added analogous checks (against null, not bool) cases on other columns on the table, like this:
ADD CONSTRAINT only_one_name_not_null CHECK (num_nonnulls(n1, n2, n3, n4) = 1)
I haven't found a solution to do the same thing but with boolean types.
Is there a way to enforce one boolean to true and the others false?