I have two fields in my table which, if they (tat and dim) are equal, I discard them i.e.
id| tat | dim | visible
1 | 11 | 22 | true
2 | 11 | 22 | false
This is considered invalid for identifiers 1and 2. Because I want to allow one dimfor tat. So I have a script that cleared these duplicates for me, and after that I added an index to this table to prevent this from happening:
CREATE UNIQUE INDEX dim_tat_idx
ON predictions (tat, dim);
As explained well in this answer:
stack overflow
Now go ahead in this case
This way you can enter (1,2), (1,3) and (1, NULL)
but neither of them a second time
What type of index would I create or what other mechanism would I use at the database level to allow a combination to be entered 1, NULL, but even more (1,2)so (1,3)?