• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data consurrency/integrity issue

 
Michael Bulpin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,
I was wondering if somebody can throw me a few thoughts on the issues of data integrity on the database side of the SCJD project.
Heres the scenario, 2 clients running in network mode, they both get a snapshot of flights and match the same flight, not uncommon.
Client 1 books 2 seats and the avaliable seats in the database is reduced by 2.
Then client 2 books 5 seats on the same flight, but has an old avaliable seats count, and that count (within the DataInfo record) is overwritten in the database with the original seats avaliable value minus client 2's requested seat booking. The result is client 1's booking has been overwritten.
How are you all combatting this:
- I can think of one way and that is to check the available seats ON THE SERVER before you perform the booking but that will be inconsistent with the current user data, and confusing to the user, unless you inform them specifically ?
Any thoughts ?
Mick
 
Michael Bulpin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Additional info,
My SCJD requirements specifically state :
"It is not necessary to provide for live updates on multiple clients when new bookings are made at other clients".
But it doesn't state that data integrity (a byproduct of this non-requirement) issues should not be resolved !
Its a curly one !
Mick
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

- I can think of one way and that is to check the available seats ON THE SERVER before you perform the booking but that will be inconsistent with the current user data, and confusing to the user, unless you inform them specifically ?

You have the right idea, and yes, it might be incosistent if the seat count in the JTable is less than the actual count in the database, but it's OK as long as you check the actual count each time the booking is requested. This is exactly what Sun wants for this assignment (I assume it is a regular assignment, not Beta).
Eugene.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An additional data point: you don't have to perform the check on the server -- in fact, I would argue that you must not perform the check on the server. Let the client handle the check. The lock() function is your friend.
- Peter
 
Michael Bulpin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter and Eugene,
Thank you for your quality comments and I have taken them both on board. I now read the target record from the server (not performing checks on server - that would violate its generic nature) and proceed to do all checks on the client, then perform the booking (via my friend lock().
I am happy with this solution. Thanks for your help guys !
Mick
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic