保持数据模型同步(MySQL 和 Neo4j)

Keeping data models in sync (MySQL and Neo4j)

昨天我看了 Greg Young 的 Polyglot Data 精彩演讲 https://www.youtube.com/watch?v=hv2dKtPq0ME&t=24m54s

虽然我全心全意地同意关键点,但并不是所有事情都清楚地实施。 他在视频的给定部分中提出的想法是,客户端必须保持自己的状态,这是合理的,但这是否意味着 MySQL 中应该有 "master" 记录以事件的形式传播到 Neo4j?

那就意味着我们必须在 SQL 中维护一个图形结构,不是吗? >.<

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?

简短回答:是的——客户端处理器跟踪它自己的读取位置,并向记录簿请求更新。它获取这些更新,将它们转化为您的 Neo4j 实例的更改,并应用这些更改。

理论上,您实际上并不需要以事件形式获取的更新 - 整个记录簿的快照就可以了;但是使用变化流可以让您处理更小的信息块,而不必担心您尚未阅读的内容会改变您目前所见内容的含义。

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

不是图形结构,不是——只是用于生成结构的所有状态。读取模型是一个视图 - 它可以忽略不相关的状态,它可以将相关状态转换为更合适的数据结构,但它不应包括任何尚未在记录簿中表示的状态。