5

I'm looking for a good way to maintain in sync local sqlite databases that could be offline to a master one, for a invoice app.

Then I read about EventSourcing and Log structured storage and wonder if it could be a better way to maintain in sync the data. However, I never before use event sourcing.

Exist a master database with all the invoice info (customers, invoices, payments, etc), and each local database in a mobile device have a full copy of it, and must stay as current as possible. Most of the time it will be on-line, but mobile internet is unreliable and could be offline for a while.

Most likely, edit on the same record is not common, even for invoice where each salesman commonly have his own subset of invoices.

Is good idea to use Event Sourcing here, or similar? Any pointers in how do this well?

The use of local sqlite is the only hard requirement, I'm totally free in the backend.

1
  • at what level of abstraction are you planning to do the event sourcing? on the level of individual DB rows this might be too granular, maybe something more high-level like an event invoice-added with a blob might be better. Also consider: What does the master do if a client sends an invalid event (e.g. adding an invoice for another customer). How does this then get rectified in the local copy?
    – marstato
    Sep 14, 2021 at 8:15

1 Answer 1

1

No, because given the detail on the question you are jumping the gun.

If you are going to find the optimal solution, you need to reason about the "conceptual" needs first, before reaching for a particular "implementation" tool.


You need to consider:

  • Will each replica have a full read-only copy of the source? Event-Sourcing is probably ideal
  • Will each replicate have a full read-write copy of the source? This gets complicated. You might be able to use Event-Sourcing, if you can separate the local INSERT/UPDATES, and track changes to replicate later back to the server. But even then, there are many complexities to consider.
  • Will each replica have a partial read-only copy of the source? You might conceptualise with Event-Sourcing, but implement with a global Event-Sourcing table, and a VIEW to filter to a subset.

There is probably more, but this section is here to illustrate the fact that you might be jumping the gun.

Your Answer

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

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