I have some table:
- table ASK with
idask
- table PREFERENCES with
idpref
,fk_idask
,fk_idstructure
- table STRUCTURE with
idstructure
With all the constraint between the id
and the fk_id
and a unique index on the table PREFERENCES (fk_idask
, fk_idstructure
).
The problem is when I have two row in PREFERENCES.
`IDPREF` `FK_IDASK` `FK_IDSTRUCTURE`
1 1 1
2 1 2
If I want to invert(switch?) the two structure between the preferences
`IDPREF` `FK_IDASK` `FK_IDSTRUCTURE`
1 1 **2**
2 1 **1**
the unique index between FK_IDASK
and FK_IDSTRUCTURE
break up, because with the first update result in two preferences for the same ask with the same structure.
For prevent this, I make a function deleteAndResave and this solve the problem for the moment.
But now the arrive the ASSIGNATION table with idassignation
and fk_idpref
.
Now if I delete a Preference linked by an ASSIGNATION the constraint break.
I already find a workaround, but is ugly. There is some sane solution for this problem?
Thanks for the answer!
ps. Sorry for my bad english :(