Hi Everyone,
This is just a simple application design question. I was just wondering how
different people would approach this problem.
Suppose you had to design a form where you edit a record and in the form
there is a list box. You can select multiple items in the list box that are
tied to that record. (Say for example, suppose you have a record that's a
car. You can select multiple options related to the car. power locks, power
windows, automatic transmission, etc) It would be a 1 - n relationship.
In the database, you have a master record in table A. (The car) And
multiple records in another table B with a foreign key relationship. (The
options on the car)
When a user submits the form. (Or clicks a button, whatever you wish) How
would you attack this problem? Delete all the records in table B and insert
the new records. Or would you compare the values of the list box and table
B and update accordingly?
Which is the better design approach?
Thanks!
dfa_geko
David McCallum - 24 Apr 2007 05:45 GMT
> Hi Everyone,
>
[quoted text clipped - 25 lines]
>
> dfa_geko
We have a similar model, what we do is maintain a toBeAdded and a
toBeDeleted list. When the model is sent to the server we just iterate
through these lists.
David McCallum
RobinS - 24 Apr 2007 06:59 GMT
I would delete the ones there, then add the new ones. Doing a match/merge
to figure out what changed, etc., isn't worth the effort unless you're
doing your own audit trailing.
Robin S.
------------------------
> Hi Everyone,
>
[quoted text clipped - 26 lines]
>
> dfa_geko
Alan T - 11 Jul 2007 01:28 GMT
Yes, I would also do the delete the old ones and then add the new ones.
> I would delete the ones there, then add the new ones. Doing a match/merge
> to figure out what changed, etc., isn't worth the effort unless you're
[quoted text clipped - 32 lines]
> >
> > dfa_geko