I have a structure which looks like
ID int Name nvarchar
ID int PersonId int Number nvarchar Make nvarchar Model nvarchar MultiSim bit
One person can have many Phones
At the moment, the logic I have is when ever the user clicks the save button, the application receives a copy of the Person object (which includes an array Phone).
As mentioned the relationship is 1 to many. As such, on save, there is only 1 person and so it's easy to update the person (no need to delete and re-add).
Currently, I delete all of the Phone's associated with the person and re-add them.
The negative that I can see is:
- Additional time is taken as it has to delete and then re-add every Phone regardless of whether there was an amendment.
- The phone ID, which auto increments, gets bigger and bigger every time this process occurs
I can't find anything to explain if my current approach is wrong or not. Should I care that the ID is getting bigger? Should I be somehow checking the current Phone objects with the ones I want to save?