In PostgreSQL I have a "cars" table (id, model, color)
How can I constrain the input color based on the model?
For example:
- if AA model then the color must be blue, red or black
- if BB model then the color must be blue, gray or black
Rather than using a condition in the constraint with the colors hard-coded, is it possible to rely on a global list of colors filtered based on the model?
Thanks for your help
2
Answers
Just have a table to record it
Not sure I understand the question, but assume:
Now, in your cars table: