Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Web Application Shared Amongst many users

 
Ayan Afridi
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am developing a web application that will be shared by many users, in which updates/adds/deletes to database tables will occurr. I am concerned about a certain scenario:

Sample table datatable:
col1 | col2 | col3
1 | y | hi

modifiable through a screen that shows all rows in this table

1. First user (A) enters the application, and views all rows.

2. Second user (B) enters application, and views all rows.

3. User A modifies row 1, to make it into : "1, x, hi"

4. User B, still sees "1,y, hi" in the view, and modifies it to "1,y,hello"

Now the table in the db will be "1, y, hello", and user A's updates will be gone. Some will say that this is ok, but if User A's change was a critical change, that effects alot of things, then User B's change will cause possibly detrimental results.

How is this usually prevented?

One way I have thought of is, not doing User B's update if the "last update timestamp" on the screen is not the same as the one in the DB. And forcing an error there.

Or, querying the db right before any update to see what is being changed.

Another way would be to refresh all the data on the screen very often - but I don't want to put that much stress on the DB; or to refresh the data once any change has occurred- this is potentially unwieldy and could cause alot of bugs.

Any suggestions? Thanks! Much Appreciated.

-Ayan
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
and welcome...

Search the web for optimistic locking...
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way I have thought of is, not doing User B's update if the "last update timestamp" on the screen is not the same as the one in the DB...

Yes, a optimistic locking example

Or, querying the db right before any update to see what is being changed.
Another way would be to refresh all the data on the screen very often - but I don't want to put that much stress on the DB; or to refresh the data once any change has occurred- this is potentially unwieldy and could cause alot of bugs.

There is no way to ensure that client view is up to date.
Logical consistency must be ensured server side.

Regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic