Skip to content

Instantly share code, notes, and snippets.

@kasei
Last active May 31, 2016 18:55
Show Gist options
  • Save kasei/6185874 to your computer and use it in GitHub Desktop.
Save kasei/6185874 to your computer and use it in GitHub Desktop.
A line-based protocol for querying and updating triple/quad stores

A line-based protocol for querying and updating triple/quad stores

Below are some thoughts on extending the RDF Patch format syntax to a line-based protocol that allows updating and querying RDF triple and quad stores. This allows triple or quad stores to be used directly by systems that require direct access to the data (e.g. with access to real blank node labels unavailable via SPARQL Query/Update). It also allows modular implementation without requiring systems to use the same language as the store (e.g. using the Jena API) or use wrappers/adapters (e.g. using things like SWIG or XS).

Operation keyword letters (arity):

A	Add / Query Result	(3/4)
D	Delete (3/4)
Q	Query (3/4)
F	Finished (0)

RDF Tuples keyword letters:

R	Repeat
U	Term Undefined

The new Q and F operation keyword letters are used to query the underlying store. A triple or quad pattern (using the U token to represent variables) and trailing DOT follows a Q indicating the query pattern. The store responds to such a query with zero or more result lines with ground triple or quad data, using the Add syntax (meaning query results are valid RDF Patch documents). After all statements matching the query pattern have been returned, a line containing a single Finished is used to indicate the completion of the query results.

Example

Example trace:

> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix foaf: <http://xmlns.com/foaf/0.1/> .
> A _:a rdf:type foaf:Person <g> .
> A <s> rdf:type foaf:Person .
> A <p> R R .
> Q U rdf:type foaf:Person .
< A <s> rdf:type foaf:Person .
< A <p> R R .
< A _:a R R <g> .
< F .

Open Issues

(none)

Changes

  • 2013.09.06
  • Changed Query syntax to use Undefined tokens instead of VAR syntax.
  • Changed the Query Result syntax to use Add, instead (allowing query results to be valid RDF Patch data).
  • 2013.09.07
  • Removed use of a token to conform with RDF Patch grammar.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment