Suppose I have 3 columns:
Critical, Medium, Low
And I have data UUID
s to be inserted from another tables. And I want to disallow insertion of same UUID in any of the column if it is already present any one of these columns. How can I do that in postgres? How should I setup my table?
example:
--------------------------
|Critical | High | Low |
--------------------------
| A | null | null |
| null | B | null |
---------------------------
Now when I try to insert B (again) in any column Critical, High or Low. It should ignore the insert.
Best Answer
Structure and predefined data:
Insertion pattern:
Retrieving the information:
fiddle
PS. The scheme does not allow to insert more than one value for the same priority in the same series also (see last insert).
PPS.
priorities
table is not used in shown code (it is used for reference integrity only), but you may...