How can I syncronise multiple mysql database, local to remote and viceversa?

I have developed a web app that runs locally via localhost, the record entered gets stored locally in the mysql database. My problem is that this application now is to be installed in multiple office locations and in each office location we need to be able to see the consolidated data from all the locations . I initially thought of connecting all the app to a consolidated  remote database and update the records to this db instead of the local mysql. But the problem is that this app has to run even when there is no internet connection, i.e when there is no net connection the records need to be stored locally and when there is internet it needs to syncronise with the consolidated db, this has to happen for at all office locations. Please suggest a solution or a tool.
Who is Participating?
grant300Connect With a Mentor Commented:
This, unfortunately, is an architectural issue.  The deployment scheme needs to be taken into account before tools are chosen and certainly before all the code was written.

Since you posted this in the Sybase area, I will go ahead an suggest you use Sybase SQL Anywhere (AKA iAnywhere, AKA Adaptive Server Anywhere, AKA ASA).

Sybase ASA has replication features specifically designed to support this kind of scenario.  It is robust, easy to use, and very cost effective.  True, it is not free but then, you are going to burn weeks or months trying to get some homebrewed solution to work.

No, replication is not the easiest way to make this all work; your gut instinct to use a centralized database is actually the right way to go.  Quite frankly, if an office is that critical, chances are loss of the internet is a bigger problem than just your app and a backup should probably be in place anyway.

That said, your unreliably connected remote offices can use ASA replication to get what you want to work.  You do definitely need a centralized consolidated server in the middle of all this as you will never succeed with an "everybody replicates to everybody" scheme.

There are issues in a scheme like this.  First and foremost is reconciling master data and IDs.  For instance, if you enter a new customers a mutliple sites, you have to have some way of assigning IDs so that there are no duplicates when they come to gether.  Like wise, if you edit the same customer at two different sites, who wins?  And of course, what happens when the same customer is entered at site A and site B?  Even if you have a mechanism to prevent duplicate IDs, you now have two versions of the same master data.

Not knowing what your application is, it is a little hard to be specific but I think it is safe to say that even switching to the best tool there is for this kind of thing, you are facing a non-trival task to fix up your database design and application code to make this a bullet-proof architecture.  If you try to short-cut things, you will forever be chained to this beast fixing data problems.

My own approach to this would be to take this in a couple of phases.  Phase 1 would be to switch to ASA.  Phase 2 would be to deploy this with one centralized database.  You can get to this point fairly quickly and with minimal expense.  You then have an opportunity to evaluate both the reliability and backup options for the Internet connections as well as time to really scope out what the database and application changes required are.  If your employer/client still insist on the distributed database architecture, then you are positioned to go forward.  If they decide they can live with the centralized database, you are already there and humming along nicely.

shankcoolAuthor Commented:
Thanks Bill, perfect answer , i was thinking of using sybase mobilink with sql anywhere locally and consolidated mysql remotely, your solution further boosts my approach.. thanks again for the wondelful help.
Glad I could help.

It sound as if you are headed in the right direction.  The only thing I would add is that keeping MySQL in the mix will only complicate things.  If you shift to ASA, go all the way.  It will greatly simplify your life and perhaps provide options not available in a mixed environment.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.