SPARQL

SPARQL (protocol SPARQL and query language RDF) in Informatique is a query language in the course of standardization within the framework of the semantic activity Web of W3C.

Language SPARQL defines syntax and semantics necessary to the expression of requests on a Database of the type RDF and the possible form of the results.

Characteristics

SPARQL is adapted to the specific structure of the graphs RDF, and is pressed on the triplets which constitute them. In that, it is different from traditional the SQL (Query language which is adapted to the databases of the relational type), but is inspired some clearly in its syntax and its functionalities. It refers also some minor of resemblance to Prolog.

SPARQL makes it possible to express interrogative or constructive requests:

  • request SELECT, of an interrogative type, makes it possible to extract from graph RDF a subgraph corresponding to a whole of resources checking the conditions defined in a clause WHERE.
  • request CONSTRUCT, of a constructive type, generates a new graph which supplements the questioned graph.
For example on a graph RDF containing of genealogical information , one will be able by a request SELECT to find the parents or grandparents of a given person, and by requests CONSTRUCT to add relations brother-sister, cousin-cousin, uncle-nephew, which would not be explicitly declared in the initial graph.

Example

Example of request SPARQL turning over a list of photographs with the name of the person which they represent and a description, starting from a Database of the type RDF using the ontology (vocabulary) FOAF (one the most known of and used to describe the people and the bonds between them).
  • Extracts from graph RDF (writing XML) of example:

Paul Dupont Pierre Dumoulin Photo of identity of Paul Dupont Photo of identity of Pierre Dumoulin

  • request SPARQL:

PREFIX rdf: < http://www.w3.org/1999/02/22-rdf-syntax-ns #> PREFIX foaf: < http://xmlns.com/foaf/0.1/ > PREFIX cd.: < http://purl.org/dc/elements/1.1/ > DISTINCT SELECT? name? image? description WHERE { ? nobody rdf: foaf type: Persson. ? nobody foaf: name? name. ? image rdf: foaf type: Image. ? nobody foaf: img? image. ? image cd.: description? description }

One notices the declaration of the spaces of names in beginning, follow-ups of the request itself. Is the name of the variable preceded by a Question mark ? .

The line SELECT makes it possible to select the whole of the tuples, or lines of variables ( name , image , description ) corresponding to the constraints of the clause WHERE.

The first line of the clause WHERE is read: the variable nobody is of type Persson within the meaning of ontology FoaF. The second line makes it possible to define the variable name as a property name of the variable nobody .

  • result SPARQL:

Pierre Dumoulin http://example.net/Pierre_Dumoulin.jpg Photo of identity of Pierre Dumoulin Paul Dupont http://example.net/Paul_Dupont.jpg Photo of identity of Paul Dupont

References

  • Specification SPARQL by the W3C
  • Schedule of conditions for the access to data RDF
  • SPARQLer - online service of request

Random links:Stalag Luft III | Television of Radio-Canada | Amenemhat III | Saint-Mard-sur-le-Mont | Thus I am… | Barry Davies | Yefim_Bronfman