I have a web form in when the user can select many available items (idFamilia) for a single Provider (idProveedor) that looks like this
The values are saved in this table
-----------------------------
| idProveedor | idFamilia |
-----------------------------
| 5 | 1 |
-----------------------------
| 5 | 2 |
-----------------------------
| 6 | 2 |
-----------------------------
After a Provider is created, it can be edited and the values selected for idFamilia can be changed. So I have three different scenarios of what could happen:
Right now I am thinking about just deleting all the rows with the idProveedor that is being edited and just insert the new selection.
Is this a good practice? Will this affect the performance on the long run?
Could you recommend a tutorial or example to do it the other way?
I always go the way to delete and re-create them.
While this adds some performance penalty, it keeps the code simple to understand and easy to maintain. Unless you're Uber, Google, Facebook, Amazon, or other world scale app, the benefits you'd get from optimizing this are much smaller than the cost it incurs: in development, debugging and maintenance time.