Question

It's one of those cases where you have a desktop application and its database is in a remote server. In my case, it's MySQL and the application is made in Delphi XE3. But when client wants his data both offline and online (for speed and security) we need to:

  1. Login with remote server information (more updated);
  2. Sync the online database to offline;
  3. Do the tasks on the application and the database;
  4. Sync back the offline database with online.

My question: Is there a standard way to do that, by MySQL instructions or another automatic way? Or Am I going to code all the rules to make it possible?

Was it helpful?

Solution

Luckily there is no need for code here.
Replication has been built into MySQL for many years.

The trick is to setup the remote host as master and the local copy as slave.
All updates go to the master.
And the slave reads from the remote.

The documentation is here: http://dev.mysql.com/doc/refman/5.7/en/replication.html
Here's a tutorial: http://www.howtoforge.com/mysql_master_master_replication

Note that there can really only be one master, if not the setup will get too complicated to be workable.

OTHER TIPS

You could look at client data sets (as you need to update the local version I do not believe that mysql allows multiple masters). Basically your application connects to mysql when it is online and if your application goes offline you store the database and changes in a local xml database. One back online, you apply the updates. Downsides of cds are.: no sql locally and your local changes might conflict with changes made by other users so the apply updates must include logic to reconcile the conflicts. Also cds is involved still trying to get my head around it

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top