• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Web Application Shared Amongst many users

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
and welcome...

Search the web for optimistic locking...
 
Oricio Ocle
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic