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
- Preliminaries: data!
- Executing a simple query
- Basic patterns
- Value constraints
- Optional information
- Alternatives
- Named Graphs
- Results
Other Material
- The SPARQL query language definition document itself contains many examples.
- Search RDF data with SPARQL (by Phil McCarthy) - article published on IBM developer works about SPARQL and Jena.
- SPARQL reference card (by Dave Beckett)
Detailed ARQ documentation