I have two tables --> Variables (id, name) and Variable_Entries (id, var_id, value).
I want each variable to have a unique set of entries. If I make the value entry unique then a different variable won't be able to have that same value which is not right.
Is there some way to make the value column unique for identical var_id's?
Yes:
alter table Variable_Entries add unique (var_id, value);
Now you have a unique constraint across var_id and value together. In other words, no occurrence of var_id and value can appear more than once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With