Knowing when to Sync 1 DB filed with its replica - How to?

Creating desktop or client-server database solutions?

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
teriibi
Posts: 252
Joined: Mon Nov 13, 2017 3:49 pm
Location: Bolivia

Knowing when to Sync 1 DB filed with its replica - How to?

Post by teriibi » Tue Jan 23, 2018 1:32 pm

Hi everyone, there is something I have always wondered about Sync. Ops.! :roll:

I m willing to understand how do programmers code their script so that a Profile user local data "knows" it has to Sync (or not to Sync) with its replica online ?
i.e. if I have a 100 users connecting to the DB online, what solution is used to decide to have their local data synchronizing with its Online equivalent ?

I had the idea that they probably have to compare the last actualizacion date (of the profile table) on each device at connection time to the one on the server ?

But More precisely, is it possible to sync just the 1 required Field no more...
Example:
If 3 users changed only their phone number localy since last connected time :
- How could I only sync their fone numbers instead of uploading their whole profile data again ?
(name, adress, fone, whatever...)

- Do coders create a "last sync date field" for each field in a profile / compare it to the one in the DB / and then decide if this field needs a Sync ?
... or is there a more Professional way to code such script/need ? :shock:

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 585
Joined: Fri Jun 27, 2008 9:00 pm

Re: Knowing when to Sync 1 DB filed with its replica - How to?

Post by Mikey » Tue Jan 23, 2018 6:33 pm

There are lots of ways to do this, including embedding a modified date stamp in a record (that can be set via a trigger, for example), a hash, etc. As far as trying to only pull a single field from a single record, that will require more effort, and I think more network activity than just pulling the entire record.

One way around this is to keep an “updates” table or file for each user/device. The mobile will pull the update info and apply it. If you are really clever, you can do this with a single table in the db with the id of the client, the timestamp, and the SQL code that you want to execute on the client to process the update. Then you are, in effect, replaying the log file from the remote server back to the local db.

Post Reply

Return to “Databases”