You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@age.apache.org by Age Apache <ag...@gmail.com> on 2022/10/03 14:16:40 UTC

How do I save history of an edge in a relation?

Hey Everyone!

Say I have following relation:

    (vertex_a:{id:uuid_value, data:json_data}) --[edge_ab:{id:uuid,
data:json_data}]--> (vertex_b:{id:uuid_value, data:json_data})

I am planning to store the history of the vertices as follows:
(The "latest_vertex" represents, for demonstration purpose, either
"vertex_a" or "vertex_b" above. The "history_root" vertex maintains
edges to all previous versions of "latest_vertex". The "latest_vertex"
maintains an edge to the "history_root".)

    (latest_vertex {uuid, data}) --[latest_created: {session,
datetime}]--> (history_root {uuid, old_vertex_ver0_uuid,
old_vertex_verN_uuid})
    (history_root) --[created: {session, datetime}--> (old_vertex_verN
{uuid, data_delta{}})
    :
    :
    (history_root) --[created: {session, datetime}--> (old_vertex_ver0
{uuid, data_delta{}})

When a vertex is created or updated following happens:
 0. A new vertex, called "old_vertex_ver{X}", is created that stores
the delta between the new data and the current data.
 1. A new edge is created between the "history_root" and the
"old_vertex_ver{X}". The content of "latest_created" edge is copied to
this new edge.
 2. The "old_vertex_verN" field of "history_root" is updated with the
UUID of "old_vertex_ver{X}".
 3. The content of the "latest_vertex" is updated with new data.
 4. The content of the edge between "latest_vertex" and "history_root"
is updated with the information of the user session and date-time of
the change.

This is to maintain history of a vertex in a graph. But how do I
maintain history of an edge, "edge_ab" in above graph?

And are there better ways to maintain history of a graph?

Thanks and kind regards,

-A