0

Background: I have a closed-source app on my laptop that saves its data in a local SQLite database. I'm working on creating a mobile app for myself that would replicate the functionality of the desktop app, but run on mobile, consequently necessitating a Cloud database, for example any of the GCP SQL offerings

Constraints: I will be the sole user of the application, so the DB writes will be very infrequent. Moreover, it can be guaranteed that no writes will happen simultaneously to the local and cloud DBs. The access pattern is more like:

  1. Do some work on the laptop, work saved to local db
  2. Sync data to cloud after app closes
  3. Open app on phone sometime later, read and write to cloud db
  4. Open laptop sometime later, get updates from cloud into local
  5. Repeat

Issue: Data needs to be eventually consistent between the mobile and the desktop app, i.e. the local SQLite and the cloud DB. I've read about multi-master replication, but this seems like an overkill since only one database is accessed at a time, and I feel that some simpler solution might fit the bill here. How could I solve this challenge?

Unsubstantiated idea?: Perhaps it would be possible to emit a Pub/Sub event on writes to either db and have a serverless function listen on local write events, replicating them to the cloud db, and a daemon on the laptop, replicating the cloud writes to local. Would something like this work?

1 Answer 1

0

If you guarantee that there is only one user at a time despite several devices going to the same database, then the easiest way would be to just copy database file. You will have some file-sharing server. At the start, the application will download the database file, work with the database, and at the end upload it back to file server. If download/upload fail - you would be informed and can decide to ignore that error if you wish.

Or, you can work with a single copy of database. Keep it on some file server, while opening directly from remote device. This can be a slow life, since each request to database will go through network, but almost zero work on data synchronization.

Or you can do a proper ETL, it is not that hard. You would still have two version of applications (desktop-mobile). And you would have to have a central database with which you would synchronize your local copies. It is the most work consuming approach.

Or you can setup a web-site with database in background and all your devices will just use browser to work with database. Zero work on different applications, guarantees that "application" on desktop will behave the same way as mobile "application" - because that would be same application running on web server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.