SPARQL Tutorial

The objective of this SPARQL tutorial is to give a fast course in SPARQL. The tutorial covers the major features of the query language through examples but does not aim to be complete.

If you are looking for a short introduction to SPARQL and Jena try Search RDF data with SPARQL. If you are looking to execute SPARQL queries in code and already known SPARQL then you likely want to read the ARQ Documentation instead.

SPARQL is a query language and a protocol for accessing RDF designed by the W3C RDF Data Access Working Group.

As a query language, SPARQL is “data-oriented” in that it only queries the information held in the models; there is no inference in the query language itself. Of course, the Jena model may be ‘smart’ in that it provides the impression that certain triples exist by creating them on-demand, including OWL reasoning. SPARQL does not do anything other than take the description of what the application wants, in the form of a query, and returns that information, in the form of a set of bindings or an RDF graph.

SPARQL tutorial

  1. Preliminaries: data!
  2. Executing a simple query
  3. Basic patterns
  4. Value constraints
  5. Optional information
  6. Alternatives
  7. Named Graphs
  8. Results

Other Material

Detailed ARQ documentation