I have designed database tables (normalised, on an MS SQL server) and created a standalone windows front end for an application that will be used by a handful of users to add and edit information. We will add a web interface to allow searching accross our production area at a later date.
I am concerned that if two users start editing the same record then the last to commit the update would be the 'winner' and important information may be lost. A number of solutions come to mind but I'm not sure if I am going to create a bigger headache.
Are there any better solutions or should I go for one of these?
The "over all" settings you are playing with don't change anything here (well except the option to open databases as shared - but that's already the default and already a given since more then one user is able to edit the data. So change the form in question locking setting to "edited" record.
Answers. You need to write SQL that prevents that. You can go fancy and create a que that syncs data or you can use concurrency that prevents record updating on records that have been modified by someone else in the same time that you were changing the same record.
Although it may seem like two users are updating the same row of data at the same time, the MySQL DBMS would prevent this from happening; instead one user's update would go first and one would go second. The result would be that both updates would go through (just not at the same time).
If you expect infrequent collisions, Optimistic Concurrency is probably your best bet.
Scott Mitchell wrote a comprehensive tutorial on implementing that pattern:
Implementing Optimistic Concurrency
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With