title: Data synchronization between two or Android devices and website
body: <p>I am building an app that allows users to insert data and synchronize with website. User can insert data on the website as well. There are two entity tables (<code>T1</code> and <code>T2</code>) and one N-M relation table (<code>TR</code>).</p>
  
  <p>Data Structure (it's just illustrative):</p>
  
  <pre><code>T1 (_id, name, modified)
  T2 (_id, name, modified)
  TR (t1_id, t2_id)
  </code></pre>
  
  <p>The problem I am facing is data synchronization of IDs. E.g. Device A1 and A2 are offline and record is inserted on both, with the ID = 1. After they are online sync starts and there is a conflict with IDs. I thought about introducing an extra column <code>gid</code> - something like global ID. So the structure would be:</p>
  
  <pre><code>T1 (_id, name, modified, gid)
  T2 (_id, name, modified, gid)
  TR (t1_id, t2_id, t1_gid, t2_gid)
  </code></pre>
  
  <p>Global ID would be assigned by website.</p>
  
  <p>But I not sure whether this is a good approach or not (never done anything like this before and cannot tell if there will be any future problem).</p>