Question

My client has a business which work mostly in remote areas where internet felicity is limited, We have a central database and the branches in remote areas need to connect to the central database.

We are developing a web-application(django, postgres) for the same, but it should work even if the client is offline.


We planning to achieve it by having a local database and sync the database with central database. (using some jobs running in the client may be celery).
We don't need to sync all the tables in the database. Among the following which is a good approach.

  1. Should the application always connect with the local database and sync the data with the remote?
  2. Should the client connect to the remote when it available and sync the rest of the data?

Let me know is there any better approaches. Thanks in advance.

Was it helpful?

Solution

As @amon already mentioned in a comment, synchronizing databases, especially if the time between synchronizations can be long, is really hard and often requires manual intervention.

I would instead look at it from a different perspective and try to create multiple applications. One application that runs entirely locally in a branch office and a second application for the centralized information.

  • First, identify which data is only needed in individual branch offices. This data would be maintained in the branch office's local application.
  • Then, identify which data is really needed by the central application. And that should not be "every sale, so we can calculate the sales volume over May", but rather "the sales volume over May".
  • Lastly, determine what the branch offices need to report to the central database. Hopefully, this is a limited amount of data (better for spotty internet connections) that only add new data to the central database. Adding new data is one of the less complicated synchronization issues.
  • That leaves us with only the updates from the central database to the branch offices. As the branch offices should operate mostly independently, those updates should be infrequent and easy to check if there was a local change to the same records.
Licensed under: CC-BY-SA with attribution
scroll top