I have a table that stores 3 values one being the primary key.
table_id, site_id, contract_id
Values are sent from a html form, I need to add more values per site_id
.
If I post values that don't already exist then it's not a problem obviously.
However the form will post the existing values as well
Example
1, 1, 1;
2, 1, 2;
3, 1, 3;
4, 1, 4;
To insert those I currently have to delete all where site_id = 1;
this is so that I don't have duplicates in the table.
Is there another efficient way to do this? I can make those composite keys to avoid duplicates but I think I will have to handle errors in that way?