Locking Database Records
How do you go about locking database records in a web application app? Say User 1 selects a record to edit and User 2 selects that same record a few seconds later, how do you deny User 2? Update a field in the database? And say User 1 is on the edit screen for 20 minutes, made a couple of changes, but never clicked submit? Do you time them out? Do you save the record then time them out? Would ajax work here? Any suggestions on how one might due this? (Using Coldfusion 8 and MySQL 5)
(Boy, that's a lot of questions)

Add a "lock" flag (column) to each table that can be edited by more than one user. Also add a "edit started" timestamp column.
When someone clicks on "edit", set that record's flag to "1" if and only if its current value is 0. Now let that person access the edit form.
If the flag is already set to 1, throw up a notice that someone else is editing that record.
When the 1st person submits the change, flip the flag back to 0.
Person 2 can now edit the record.
To address the "stepped away" issue, run a scheduled task every 30 minutes or so. Look for records with a flag = 1 and an edit start time > 30 minutes. Adjust the timing as you like.
I did this with an application for US Airways and it worked out very well for all involved.
@Matt, Do you know of any examples?
"Unlike database solutions that store a flag in a record LockMonger works by storing information in an application-scoped array, so there is zero chance that two users can collide."
http://mysecretbase.com/lockmonger.cfm