Mysql - Deleting items omitted from an insert|update
July 7, 2006 2:01 PM
Subscribe
MysqlFilter: I need someone with mighty mysql-Fu to help me out here.
I have a list of items stored in my database (60 or so per user), they get sent to the flash application that I have, then once the user is done with everything, they press "save" (20 to 60 times a day), and it saves the list of items back to the database. I was doing an insert on duplicate update, but this doesnt get rid of the items that may have been deleted.
So my question is this, should I:
A) Delete all items first, then insert all new records.
B) Keep a list of things that have been deleted in the program, and send that list back with all of the other data.
C) Add a last modified timestamp and delete anything that wasn`t updated in the last minute
This isn`t a huge application, and definitely won`t be public... I can`t imagine more than two people using this concurrently, but beings that the mysql database is on my desktop, its in my best interest if I keep things quick, and in everyone`s best interest if I keep things responsive.
Will I notice if I just delete&insert? What would the difference in load be? Would it be worth my time to program in B or C?
Thanks!
posted by hatsix to technology (10 comments total)
If you can detect in your interface that an item has been changed or marked for deletion, delete it or updated it in the database accordingly, otherwise leave it alone. Basically your b and c combined above.
However, if you don't mind a tremendously kludgy solution, a will work - but even with just 2 people using it concurrently, that's a dangerous one.
Is it very important to be able to edit multiple items really quickly? Could you just list each of the items and have:
- at the top of the list, an add button to add a new item
- next to items, a "delete" button and an "edit" button allowing to delete/update those items...
Or would that type of interface slow down your process too much?
posted by twiggy at 2:28 PM on July 7, 2006