Wolfram Language

Symbolic SPARQL

Version 12 introduce a symbolic representation of SPARQL, the query and update language for RDF (the Resource Description Framework).

See how to compose a simple symbolic SPARQL query. First, load GraphStore and store an example RDFStore object about fruits in a variable for later querying.

The basic constituent of a SPARQL graph pattern is the triple pattern, which is represented as an RDFTriple. During query evaluation, a triple pattern is matched against triples in the RDF store. A SPARQLVariable in a triple pattern acts as a placeholder. Define two triple patterns, one to match "color" triples and another one to match "shape" triples.

Now combine the patterns, marking the "shape" pattern as optional using SPARQLOptional. In general, graph patterns can be combined using a List ({}) to form so-called "group graph patterns" (or "basic graph patterns" if the list contains only triple patterns).

Then choose the SPARQLSelect query operator, which takes a SPARQL graph pattern and yields as a result a list of associations.

Finally, apply the query to the store.

Related Examples

de es fr ja ko pt-br zh