Data synchronization between two or Android devices and website -
i building app allows users insert data , synchronize website. user can insert data on website well. there 2 entity tables (t1
, t2
) , 1 n-m relation table (tr
).
data structure (it's illustrative):
t1 (_id, name, modified) t2 (_id, name, modified) tr (t1_id, t2_id)
the problem facing data synchronization of ids. e.g. device a1 , a2 offline , record inserted on both, id = 1. after online sync starts , there conflict ids. thought introducing column gid
- global id. structure be:
t1 (_id, name, modified, gid) t2 (_id, name, modified, gid) tr (t1_id, t2_id, t1_gid, t2_gid)
global id assigned website.
but not sure whether approach or not (never done before , cannot tell if there future problem).
you have use additional ids, suppose network_id, generate network_ids on server , use local ids on devices (e.g. uuid). when sending create entity request server generate real id , return you, can update local database network_id. important use network_id main field , local_id if don't have network_id.
Comments
Post a Comment