Similar to other questions asked but haven't found a normalized solution for TEXT[]:
Postgres check constraint in text array for the validity of the values
- does not use another table as a check
https://dba.stackexchange.com/questions/250659/constrain-array-values-to-an-allowed-set-of-values
- same solution as above but mentions a normalized solution
Check if value exists in postgres array for partitioning via check constraint
- similar
Postgres ENUM data type or CHECK CONSTRAINT?
- great answer and is a normalized solution but only for
TEXT, notTEXT[]
I have two tables articles and valid_tags. valid_tags holds text values that are only allowed. When an article is INSERTed the tags TEXT[] column must be an array of valid tag values. I need to check those values against the valid_tags table.
CREATE TABLE articles (
tags TEXT[]
);
CREATE TABLE valid_tags (
name TEXT
);
I'm looking for a very similar solution as Postgres ENUM data type or CHECK CONSTRAINT? but with the constraint that column color_id is TEXT[].