Keeping data models in sync (MySQL and Neo4j)

331 views Asked by At

Yesterday I watched an amazing talk Polyglot Data by Greg Young https://www.youtube.com/watch?v=hv2dKtPq0ME&t=24m54s

And while I wholeheartedly agree with key points, it's not everything clear implementation wise. The ideas that he's pushing in the given part of the video is that client must maintain it's own state, which is reasonable but does that mean that there should be a "master" records in the MySQL that will be then propagated to the Neo4j in form of events?

That would meen that we have to maintain a graph structure in the SQL, aren't we? >.<

1

There are 1 answers

0
VoiceOfUnreason On BEST ANSWER

The ideas that he's pushing in the given part of the video is that client must maintain it's own state, which is reasonable but does that mean that there should be a "master" records in the MySQL that will be then propagated to the Neo4j in form of events?

Short answer: yes -- the client processor keeps track of its own read position, and asks the book of record for updates. It takes those updates, translates them into changes for your Neo4j instance, applies those changes.

In theory, you don't really need the updates fetched in the form of events - a snapshot of the entire book of record would work; but working with streams of changes allows you to process smaller chunks of information without worrying that something you haven't read yet will change the meaning of what you have seen so far.

That would mean that we have to maintain a graph structure in the SQL, aren't we?

Not the graph structure, no -- just all of the state used to generate the structure. A read model is a view - it can ignore irrelevant state, it can transform the relevant state into a more appropriate data structure, but it shouldn't include any state not already represented within the book of record.