SPARQL

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Romeokienzler (talk | contribs) at 09:15, 27 April 2012. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

SPARQL (pronounced "sparkle", a recursive acronym for SPARQL Protocol and RDF Query Language) is an RDF query language, that is, a query language for databases, able to retrieve and manipulate data stored in Resource Description Framework format.[1][2] It was made a standard by the RDF Data Access Working Group (DAWG) of the World Wide Web Consortium, and considered as one of the key technologies of semantic web. On 15 January 2008, SPARQL 1.0 became an official W3C Recommendation [3][4].

SPARQL allows for a query to consist of triple patterns, conjunctions, disjunctions, and optional patterns.[5]

Implementations for multiple programming languages exist.[6] "SPARQL will make a huge difference" according to Sir Tim Berners-Lee in a May 2006 interview.[7]

There exist tools that allow one to connect and semi-automatically construct a SPARQL query for a SPARQL endpoint, for example ViziQuer.[8] In addition, there exist tools that translate SPARQL queries to other query languages, for example to SQL[9] and to XQuery[10].

Benefits

SPARQL allows users to write unambiguous queries. For example, the following query returns names and emails of every person in the dataset:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?email
WHERE {
  ?person a foaf:Person.
  ?person foaf:name ?name.
  ?person foaf:mbox ?email.
}

This query can be distributed to multiple SPARQL endpoints (services that accept SPARQL queries and return results), computed, and results gathered, a procedure known as federated query.

Query forms

The SPARQL language specifies four different query variations for different purposes.

SELECT query
Used to extract raw values from a SPARQL endpoint, the results are returned in a table format.
CONSTRUCT query
Used to extract information from the SPARQL endpoint and transform the results into valid RDF.
ASK query
Used to provide a simple True/False result for a query on a SPARQL endpoint.
DESCRIBE query
Used to extract an RDF graph from the SPARQL endpoint, the contents of which is left to the endpoint to decide based on what the maintainer deems as useful information.

Each of these query forms takes a WHERE block to restrict the query although in the case of the DESCRIBE query the WHERE is optional.

Example

Another SPARQL query example that models the question "What are all the country capitals in Africa?":

PREFIX abc: <http://example.com/exampleOntology#>
SELECT ?capital ?country
WHERE {
  ?x abc:cityname ?capital ;
     abc:isCapitalOf ?y .
  ?y abc:countryname ?country ;
     abc:isInContinent abc:Africa .
}

Variables are indicated by a "?" or "$" prefix. Bindings for ?capital and the ?country will be returned.

The SPARQL query processor will search for sets of triples that match these four triple patterns, binding the variables in the query to the corresponding parts of each triple. Important to note here is the "property orientation" (class matches can be conducted solely through class-attributes or properties - see Duck typing)

To make queries concise, SPARQL allows the definition of prefixes and base URIs in a fashion similar to Turtle. In this query, the prefix "abc" stands for “http://example.com/exampleOntology#”.

SPARQL/Update

SPARUL, or SPARQL/Update, is an extension to the SPARQL query language that provides the ability to add, update, and delete RDF data held within a triple store.

SPARQL implementations

This list shows triplestore, APIs, and other storages that have implemented the SPARQL query language.

  • 4store
  • AllegroGraph
  • ARC2
  • ARQ
  • BigData
  • BrightstarDB
  • Corese
  • D2R Server
  • Dydra
  • Hercules
  • Intellidimension Semantics Platform 2.0
  • Jena
  • KAON2
  • Knowledge Explorer
  • Mulgara
  • OntoBroker
  • Ontotext OWLIM
  • Open Anzo
  • OpenLink Virtuoso
  • Oracle DB Enterprise Ed.
  • Parliament
  • Pellet
  • RAP
  • RDF API for PHP
  • RDF-3X
  • RDF::Query
  • Redland / Redstore
  • SPARQL Engine
  • SemWeb.NET
  • Sesame 2
  • Stardog
  • StrixDB
  • Twinql
  • Web Query
  • IBM DB2[11]

References

  1. ^ Jim Rapoza (2 May 2006). "SPARQL Will Make the Web Shine". eWeek. Retrieved 17 January 2007.
  2. ^ Segaran, Toby; Evans, Colin; Taylor, Jamie (2009). Programming the Semantic Web. O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. p. 84. ISBN 978-0-596-15381-6.
  3. ^ "W3C Semantic Web Activity News - SPARQL is a Recommendation". W3.org. 15 January 2008. Retrieved 1 October 2009.
  4. ^ "XML and Semantic Web W3C Standards Timeline" (PDF). 4 February 2012.
  5. ^ "XML and Web Services In The News". xml.org. 6 October 2006. Retrieved 17 January 2007.
  6. ^ "SparqlImplementations - ESW Wiki". Esw.w3.org. Retrieved 1 October 2009.
  7. ^ Reuters (22 May 2006). "Berners-Lee looks for Web's big leap". zdnet.co.uk. Archived from the original on 30 September 2007. Retrieved 17 January 2007. {{cite news}}: |author= has generic name (help)
  8. ^ "ViziQuer a tool to construct SPARQL queries automaticly". lumii.lv. Retrieved 25 February 2011.
  9. ^ "D2R Server". Retrieved 2012- 02-4. {{cite web}}: Check date values in: |accessdate= (help); Cite has empty unknown parameter: |1= (help)
  10. ^ "SPARQL2XQuery Framework". Retrieved 2012- 02-4. {{cite web}}: Check date values in: |accessdate= (help); Cite has empty unknown parameter: |1= (help)
  11. ^ "NoSQL Graph Store". 27 April 2012.

External links