Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

While I was familiarizing myself with all the new data types in MySQL, I noticed the TIMESTAMP data type, and thought "What if I make this TIMESTAMP field and the CustomerID field (the other pk) a composite primary key?" That way, if two people try to submit updates to a record at exactly the same time, they will get an error.

Am I an evil genius, or this just stupid?

share|improve this question
Seems like a terrible idea. What if the a user submits an update to the record 1 second after the first user? What is the UI sitting in front of this? A PHP app or something? You're probably better off handling edits in the UI - have a is_locked column that gets set to 1 when a user opens the record for edit. If the UI for the end application is MySQL Workbench, nobody can help you :) – Phil Apr 9 '12 at 20:55
Lol, thankfully MySQL Workbench isn't the UI. HTML and PHP will comprise/power the app. – Emeril Apr 9 '12 at 20:57
Have a "Edit this record" button on the UI that then sets the locked flag in the DB. If another user attempts to do the same thing on the same record, they should get an error. This is more of an application/UI design issue and not a database problem. – Phil Apr 9 '12 at 20:58
@Phil, thanks, that makes a lot of sense. Thanks for the help. – Emeril Apr 9 '12 at 20:59

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.