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.


google has implemented an editing surface from scratch and that too in JavaScript




The solution that springs to my mind is like this:

  • Store the document in a version control system
  • When viewing, the user gets the latest version as of that moment
  • When saving, a new version gets created. If the VCS changes have been committed in the meantime, an automatic merge is attempted.
  • If the merge fails, the user is alerted that conflicting changes have been made and is asked to resolve the conflicts.
  • If the merge succeeds, the merged version is stored.

This assumes that the document is stored in a format that allows comparissons and merges.

  • one day i'llwrite my own editor like the google one, till then im gonna stick to a solution more or less like you have suggested... – dakait Feb 18 '13 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.