Data and database sync or replication for Desktop and iOS

Many entries about “sync” in this forum, but no solution. Is there anybody who has a solution or can write a plugin for this. Maybe someone of you can discuss it at the XDC.

Database sync is a science… one that I have yet to find an easy way to deal with.
I am creating an app for mobile devices which will have a counterpart on desktop… where entries can be made, deleted or modified on either platform, but the results at some point need to be synchd so both devices say the “same thing”.

To prepare for the future, the database will have at least two “special” fields.

  • UID - each record will have a unique identifier. this will make it easy to determine records that don’t exist in the “other” DB
  • Status - new, changed, deleted… Deleted records won’t be physically removed until data is synched

Of course this doesn’t address “THE PROCESS”, especially if you need to synch MULTIPLE devices

For speed (and again future)… I am planning on using the iTunes Filesharing portal to give the desktop access to “both” the desktop and mobile copies… allow it to do the updates, and then move the new database back to the mobile device.

at least that is my thought process as of now.

Sync is not a topic for a plugin.
It may be a class to buy, but it can only work, if you design tables to prepare for sync (With UUID keys and timestamps) and than sync them with two database connections.
The plugin can help connecting like our MBS SQL Plugin, which connects to 14 different database types.

I’m also interested in this topic. I experimented with UUID keys but they just made the database really huge (sqlite). If anyone has tips or examples that would be awesome :slight_smile:

Apples CloudKit could do that for you. Google Firebase is another solution without Apple in it :wink: And many more…
You get a db (offline useable), that syncs (when online) with the cloud so you get your data synced to different devices.

@Marius Dieter Noetzel : did you build a xojo app using firebase or cloudkit ?

I did something with firebase.
Want to try cloudKit next time

[quote=384388:@Marius Dieter Noetzel]Apples CloudKit could do that for you. Google Firebase is another solution without Apple in it :wink: And many more…
You get a db (offline useable), that syncs (when online) with the cloud so you get your data synced to different devices.[/quote]
neither (or similar) are an acceptable solution… primarily since this data will not reside in the cloud, but must reside in an SQLite database hosted by the mobile and/or desktop devices involved.

For my database sync feature, each user have a unique user ID (not UUID). Each record have a unique ID. When the user add a new record, this user ID is included in the record unique ID. I sync with the help of Timestamp field.

The “users” are not important (even if you have many)… what IS important is the “transaction”… was a record added? deleted? or changed? and how to handle situations that conflict between two instances of the database.

  • Added to “A”?, sync says to add that same one to “B”
  • Deleted from “A”, and exists in “B” and not touched in “B” since last synch, delete from “B”… otherwise do what?
  • Changed in “A” and exiss in “B” and not touched in “B” since last synch, update “B”,… otherwise do what?

Those are just a few scenarios

I use the user ID included in the “transaction” ID to be sure it’s unique. That’s my pseudo UUID.

and how to you insure those ids are in fact “unique” between multiple databases?

In my schema, only one database has an admin status. It’s the only one that may give a user ID and subsequent new database are created (duplicated) by this admin database (more exactly by the application that use this database).