In the table, I have 3 columns:
id
tag1
tag2
id is the primary key.
And I want only one unique combination of tag1-tag2 in this table.
for example, if one record looks like this:
id: 1
tag1: cat
tag2: dog
I do not want a second entry like this to be inserted:
id: 2
tag1: cat
tag2: dog
So, I made all the primary keys from 3 columns, but the problem is that then the second record will be inserted, since it looks like in a combination of all 3 of them.
How can I solve this problem, so that the only combination of tag1 and tag2 is unique?
UPDATE: I added a unique tag1 and tag2 tag. however, it can still be inserted:
id: 3
tag1: dog
tag2: cat
Is there any way to prevent this?
ajsie source
share