Offline sync pattern where client needs subset of large dataset

Offline sync pattern where client needs subset of large dataset


Hi all,

I have a large table on the server. I need my clients to have a far smaller subset for use offline and to sync that back afterwards, this goes for a number of tables and some tables ref others wth foreign keys.

With all that in mind I think I need the Ids of the local database copies to match the servers, how else to maintain reference relationships between tables?

This is where I'm unsure: I want to only get data from certain large tables which pertain to the particular user, I don't want them creating giant local tables for security, for performance (both at sync and during lookups to display and manipulate data)

But if I try to sync only say records with Ids 3, 4 and 5, will the local db like that? will it not surely complain that local record with Id 1 & 2 dont exist and refuse to create non contiguous Ids? Maybe im imagining that and it'll be fine. Obvioulsy I can engineer logic to deal wiht this, I could create another field on the local table containing the key value for the serverside database and then use that in comparisons and when creating records. But that will be a lot of faff and I do have about 10 tables to setup sync for, I'm going to make errors and have to debug and yeah... doable but maybe there is a better way or no issue in the frist place.

Hope my desicription makes sense and as always: thanks for any advice or help anyone can give.
Best regards,

Hi Danny,

From what I understood from your description... no issue in the first place. No problem with the ids that come from the database into local storage.

You will have problems if 

  • the same records go to different devices and can be updated in both devices.  You can follow one of this patterns:

  • Or if offline you create records that have references to it. In that case you can follow this pattern:

If it's both situations you will have to do sort of a merge between the patterns.