Just wondering if this can be enforced by the database or not…
I have a table that has a foreign key, and another column that needs to be unique across rows where the foreign key is the same. Duplicate entries are allowed as long as the foreign keys are different.
Is there a way to do this? I can’t seem to figure out a way to set a unique constraint that is based on some condition rather than applied to the entire table.
You can create
UNIQUEconstraint on both columns too.UPDATE 1