How could I guarantee that two columns don’t have repeated values within the scope of a third column?
I’m trying to guarantee that there are no duplicated rows for a given table on my POSTGRESQL database, under the following criteria:
Say there are three columns: column_scope, column_1 and column_2. I want to ensure that in the scope of a given column_scope’s value, there aren’t any rows that have the same value for column_1 on their column_2, and vice-versa.
That is, within the scope, the only way for a column_1 to have the same value as a column_2, is either for both of them to be NULL or for them to be the same row.