A basic problem that I encountered when I started to developed a stand-alone application involving the use of a DB, which is Service Publishing AP's service_list, as opposed to a web application is to decide whether I should employ locking or copying when using an iterator to iterate, for example, a shared linked list or a shared DB. After some thoughts, I base the decision on the nature of the usage of the iterator. If the usage can be predicted to be fast and have a definite end like updating a shared linked list of USB devices, locking is appropriate. But, if the duration of the usage cannot be predicted or expected to take a long time, copying is more appropriate like reading the whole content of a file into memory instead of locking the file with a reader-writer lock.
In the case of developing a web application in which a PHP script in the server reads the result set of a DB query to construct a HTML table to be sent to a client's web browser and in which a JavaScript in the client's web browser provides facility to sort the data in the table based on a certain column key or to edit the data directly in the HTML table, I am not aware of the basic iteration problem because it is solved automatically: the PHP script in the server employs locking to read the data quickly and the JavaScript that helps the user to tinker with the data actually acts on the copy of the underlying DB data. But, I encounter the problem of outdated data, for example, the data that the user has been tinkering with are deleted by his colleague from the DB so that when the web browser sends the updated data, the update statements on the DB will fail since there is no data to update.