Redland contexts

How contexts work in Dave Beckett’s Redland RDF library:

  • When a triple is created, then any RDF node (URI, blank node, literal) can be attached to the triple. This becomes the context node.
  • A triple can be added to a graph multiple times with different contexts (Redland graphs are bags of triples, not sets).
  • A context node can be specified when searching for triples matching a pattern.
  • A context node can be specified when triples are removed
  • I’m not sure what happens when triples are searched or removed and no context node is specified — does it match triples with context? I suppose yes, but the docs don’t tell.
  • I’m not sure if two statements with different contexts are considered equal. I suppose yes, but the docs don’t tell.

I believe this is largely compatible with SPARQL’s RDF datasets, except for two things:

  • Graph names can only be URIs, while contexts can be any kind of RDF node.
  • Blank nodes can never be shared between multiple graphs, but can be shared between contexts.

Redland graphs have always allowed duplicate triples. This design predates the Working Group decision that graphs are sets of triples. I wonder how the design of contexts would have turned out if Redland graphs were sets.

This entry was posted in General, Semantic Web. Bookmark the permalink.