Skip to content

Instantly share code, notes, and snippets.

@howarddierking
Created December 20, 2019 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save howarddierking/5362359b4f4e31849bf146a943cefbba to your computer and use it in GitHub Desktop.
Save howarddierking/5362359b4f4e31849bf146a943cefbba to your computer and use it in GitHub Desktop.
#
# Scenarios
# 1. see the change history for an entity
# 2. refer to the entity in a non-versioned manner for ease of access
# 3. manage the size of the graph (e.g. reduce data duplication where possible)
# 3.a. for literals
# 3.b. for references to other entities
# Notes
# - any change operation on an entity MUST update the respective EntityHead for the entity with the pointer to the latest EntityVersion (this should be the only mutation)
# - another notable difference between git and this exploration is that the unit of immutabilty in git is a blob (a file) and the state of the repository is the state of the tree pointed to by the commit - TODO: is the tree a snap of *all* versioned blobs? If so, perhaps the only real difference here is that this application includes literals, which could increase the storage footprint of a tree analog.
# sample entity
# a HEAD resource identifier (HEAD is implicit in this approach since unlike git, we're not trying to support a broader tagging functionality)
</person/48486d4d-ec83-4028-a78a-8618534d495d>
a :Person, :EntityHead ;
:head </person/48486d4d-ec83-4028-a78a-8618534d495d/v:afea0618-42f3-43f5-9dc7-e0a5a538d713> .
# most recent version as indicated by :head
</person/48486d4d-ec83-4028-a78a-8618534d495d/v:afea0618-42f3-43f5-9dc7-e0a5a538d713>
a :Person, :EntityVersion ;
:parent </person/48486d4d-ec83-4028-a78a-8618534d495d/v:676d7e81-cc4d-4de7-8a57-45dc657b09eb>
:event </event/89c4f433-58b8-4d89-814b-cf2685f5326a> ; # can tie the change to the source event(s) that produced the version
:firstName "Howard" ;
:lastName "Dierking" ;
:friendOf </person/f1269992-04cb-4b1a-9b71-ef40d99d430e> . # always point at HEAD
# the initial EntityVersion won't have a :parent
</person/48486d4d-ec83-4028-a78a-8618534d495d/v:676d7e81-cc4d-4de7-8a57-45dc657b09eb>
a :Person, :EntityVersion ;
:event </event/8ed627c7-c1d1-432c-baae-b7d8e679af99> ;
:firstName "Howard" ;
:lastName "Dierking" .
:friendOf </person/f1269992-04cb-4b1a-9b71-ef40d99d430e/v:df59d103-04e2-4ecf-9845-313b7c9c49a6> . # point at specific version (depends on the entity)
# sample related entity
</person/f1269992-04cb-4b1a-9b71-ef40d99d430e>
a :Person, :EntityHead ;
:head </person/f1269992-04cb-4b1a-9b71-ef40d99d430e/v:df59d103-04e2-4ecf-9845-313b7c9c49a6> .
</person/f1269992-04cb-4b1a-9b71-ef40d99d430e/v:df59d103-04e2-4ecf-9845-313b7c9c49a6>
a :Person, :EntityVersion ;
:firstName "A" ;
:lastName "Friend" .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment