Skip to content

Describing a Union of Changes to a Named Graph

Peter F. Patel-Schneider edited this page Nov 30, 2023 · 5 revisions

Describing a Union of Changes to a Named Graph

This is a clean version of https://github.com/w3c/rdf-ucr/issues/23#issuecomment-1712809669

This is about a "blame" view of the version history of a metadata record. Each version is a distinct named graph, and a union of their triples, annotated with source graphs, represent the blame view.

It is extra interesting due to our expected use of RDF-star within each version.

Here are the two versions expressed as named graphs using TriG-star:

prefix : <http://example.org/ns#>
base <http://example.com/>

graph <data?version=1> {
  <7d5d0d651caa> a :Work .
}

graph <data?version=2> {
  <7d5d0d651caa> a :Text .
  << <7d5d0d651caa> :subject <semantics> >> :suggestedBy <classifyer> .
}

Here is the blame view of that, combining asserted and quoted facts (utilizing annotation to avoid repeating asserted arcs with additional attached facts):

prefix : <http://example.org/ns#>
base <http://example.com/>

<7d5d0d651caa> a :Text {| :statedIn <data?version=2> |} .
<< <7d5d0d651caa> a :Work >> :statedIn <data?version=1> ; :retractedIn <data?version=2> .
<< <7d5d0d651caa> :subject <semantics> >> :suggestedBy <classifyer> {| :statedIn <data?version=2> |} .

While repetitive, the above is still more concise (and possibly different in terms of referential opacity) than using plain old reification (here in Turtle):

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix : <http://example.org/ns#>
base <http://example.com/>

<7d5d0d651caa> a :Text .
[] rdf:subject <7d5d0d651caa> ;
  rdf:predicate rdf:type ;
  rdf:object :Text ;
  :statedIn <data?version=2> .

[] rdf:subject <7d5d0d651caa> ;
  rdf:predicate rdf:type ;
  rdf:object :Work ;
  :statedIn <data?version=1> ;
  :retractedIn <data?version=2> .

_:stmt3 rdf:subject <7d5d0d651caa> ;
  rdf:predicate :subject ;
  rdf:object <semantics> ;
  :suggestedBy <classifyer> .

_:stmt4 rdf:subject _:stmt3 ;
  rdf:predicate :suggestedBy ;
  rdf:object <classifyer> .

_:stmt4 :statedIn <data?version=2> .

This use case, along with details pertaining to JSON-LD, is described in more detail in https://github.com/json-ld/json-ld-star/issues/45.

Analysis

One difference between the RDF-star representations and the reification versions is that there is only one quoted triple with the same subject, object, and predicate. So in reification one can write

[] rdf:subject <7d5d0d651caa> ;
  rdf:predicate rdf:type ;
  rdf:object :Text ;
  :statedIn  ;
  :from  .

[] rdf:subject <7d5d0d651caa> ;
  rdf:predicate rdf:type ;
  rdf:object :Text ;
  :statedIn  .
  :from  .

and not have conflation of the links on the two statings. With quoted triples there needs to be separate stating objects, as in

<< <7d5d0d651caa> rdf:type Text >>
   :occurence [ rdf:type :stating,
   	        :statedIn  ;
   	    	:from  ] ;
   :occurence [ rdf:type :stating,
   	      	:statedIn  ;
 		:from  ] .

So the succintness different is not as great as shown above and does not remove the need for blank nodes (or generated IRIs).

The other difference has to do with transparency. The RDF reification version is transparent but simulates a kind of opacity by having different reifications of the same triple. The quoted triple version has the opacity of the underlying semantics of quoted triples. Whether this is benefit depends on what transparency is wanted in the use case.