title: Two-way syncing with iPhone and Web service
body: <p>Yeah I know there are couple of questions which are related to syncing with iPhone and Web DB but none of them helped me. 
  I also did a lot googling but I rarely found informations about two-way-syncing. Maybe I just used the wrong keywords.</p>
  
  <hr>
  
  <p>I'm building an App right now and I came up with the idea to add a two-sync to my App and my Web service.
  My first thought were that it would be ridiculously easy but it turns out to be not that easy at all.
  I found couple of problems and some solutions to my problems but I would like to hear from you guys if these soultions would create other problems or if these solutions are good or bad.</p>
  
  <p>The idea of my App is helping me sync my notes which I will take on the go with my iPhone and at work or at home with a Web App.
  Those two ends should always sync'd cause I don't know on any time which device (iPhone or Computer) I will use to take, edit or just read my notes.</p>
  
  <p><strong>What I have on both sides:</strong></p>
  
  <p>For my Web service (and web app) I will use rails and I think mysql on the DB side.
  On the iPhone I will use a SQLite DB with a Objective-C wrapper (FMDB).
  Both will exchange data via JSON (using a JSON framwork on iPhone side).</p>
  
  <p><strong>My ideas so far:</strong></p>
  
  <ol>
  <li><p>Primary key has to be unique on both sides</p>
  
  <p>As a primary key I will use a <code>UUID</code>. I think it's a unique solution on both sides and it won't make any duplicates (at least I hope).</p></li>
  <li><p>Revisions for changes of data</p>
  
  <p>Each change will be saved as revision with a <code>SHA1</code> key, which I will create from <code>date + note data</code>.
  The revision object is also including information like:</p>
  
  <ul>
  <li>date</li>
  <li>which note object belongs to this revision</li>
  <li>changes are made on which device?</li>
  <li>what chaged? (atually I'm not sure about including this information)</li>
  </ul></li>
  </ol>
  
  <p>My "solution" so far is I will track every modification (create, update, delete) on a histroy-table with revisions on both sides.
  On the iPhone side I will first update my history-table from Web DB and then commit my changes to the Web DB. 
  This should work, right?</p>
  
  <p>That sounds not that bad to me but my question here is how can I handle conflicts? I don't want to bother the user with messages how to handle the conflicts.</p>
  
  <p><strong>Roundup of my questions:</strong></p>
  
  <ol>
  <li>Is my "solution" good or bad? What should I change to make it better?</li>
  <li>How can I handle change conflicts so the user don't notice them?</li>
  <li>Do you have any resources I could read about two-way-sycing?</li>
  </ol>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Thank you all for your answers. I know now that I'm not alone with this "problem" and there is no simple and all fitting solution for all Apps. I assume that I'm doing good with my ideas or solutions so far and I will try to come up with syncing rules.</p>
  
  <p>My idea so far is: I will develop it simple as possible and will use it for my own needs. Solve problems I discovered while using and syncing. After that I will invite my friends to test and solve problems they have.
  I think this way I can came up with real world rules for syncing my data with Web cause I see what people are actually doing and where problems are.</p>
  
  <p>What you think?</p>