So I have a relatively simple system. A mobile client creates records in a sqlite database that I would like to have synced to a remote SQL server (that is shared with other mobile clients). So when I create a new record in the phone’s sqlite table, I then push that change to my remote service through a RESTful API. The problem I’m having, is how do I order the primary keys so that there isn’t collisions in the data (i.e. a record in the phone has the same primary key as a completely different record on the server). What is the usual “best practice for referencing the record on the client, and for referencing the same record on the server?
Share
You could use a GUID type of column for the primary key. SQL Server supports the type
UNIQUEIDENTIFIERSQLite supports the typeGUIDas far as i know (otherwise your client app on the phone has to produce a GUID value). This should guarantee unique values on client and server.