i have a scenario where i have to make available a document for viewing and editing to multiple users, the users can edit and view the document at the same time. Now the problem arises here if for example user A and user B are viewing a document at the same time and if both the user change the state of the document and user A saves it at x instant of time and user B saves it at y instant of time where y>z in the time dimension. The changes by the user A will be overridden by changes made by the user B.
Possible solutions that i have in mind
(1) i'll keep a bit e.g. isViewedCurrently and only allow a single user to view/edit the document,
(2) save changes of every user separately and then appoint a role who will merge those changes (impractical)
please suggest some solution that i can implement, can anyone explain how google does it, the google docs are shared, viewed and edit by multiple users and changes of each user is persisted.
im using SQL server 2008 R2 for persisting the application data.
EDIT:
google has implemented an editing surface from scratch and that too in JavaScript