The W3C RDF Data Access Working Group has published three candidate recommendations about SPARQL:
According to the introduction to SPARQL Query Language,
An RDF graph is a set of triples; each triple consists of a subject, a predicate and an object. RDF graphs are defined in RDF Concepts and Abstract Syntax [CONCEPTS]. These triples can come from a variety of sources. For instance, they may come directly from an RDF document; they may be inferred from other RDF triples; or they may be the RDF expression of data stored in other formats, such as XML or relational databases. The RDF graph may be virtual, in that it is not fully materialized, only doing the work needed for each query to execute.
SPARQL is a query language for getting information from such RDF graphs. It provides facilities to:
- extract information in the form of URIs, blank nodes, plain and typed literals.
- extract RDF subgraphs.
- construct new RDF graphs based on information in the queried graphs.
As a data access language, it is suitable for both local and remote use. The companion SPARQL Protocol for RDF document [SPROT] describes the remote access protocol.
Here's a simple example SPARQL query adapted from the draft:
PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX : <http://example.org/book/> SELECT ?var WHERE ( :book1 dc:title ?var )
The ?
indicates a variable name. This query stores the
title of a book in a
variable named var
. There are boolean and numeric operators as well.
Strangely you can also use a dollar sign to represent a variable name. As far as I can tell this is exaclty the same as using a question mark. Why two forms? I don't know but I can guess. This really smells of a massive and pointless argument within the working group that was resolved by agreeing to do both when only one was necessary.
Comments on all three CRs are due by June 6.