SPARQL

From semantic-mediawiki.org
Jump to: navigation, search

SPARQL (SPARQL Protocol And RDF Query Language) is a standard query language for data on the web which in turn is expressed in RDF). It was standardized by the W3C and released as a W3C Recommendation on 15 January 2008.1 The succeeding SPARQL 1.1 was released as a W3C Recommendation on 21 March 20132 which added update capabilities and is already supported by many implementations.

With SPARQL you can ask an endpoint for any answers that match a specific pattern that you provide. For example, asking

SELECT ?event WHERE {
  ?e <http://www.semanticweb.org/id/Property-3AHas_location_city> <http://www.semanticweb.org/id/Beijing> .
  ?e rdfs:label ?event
}

will return the label of all events that are located in Beijing (or, more exactly, all labels of entities that are subject in a triple with the property http://www.semanticweb.org/id/Property-3AHas_location_city and the object http://www.semanticweb.org/id/Beijing .)

SPARQL in Semantic MediaWiki

Since Semantic MediaWiki 1.6.0Released on 30 July 2011 and compatible with MW 1.15.x - 1.18.x. RDF databases can be used to store data that then offer SPARQL web services for querying the wiki. This support was substantially improved with Semantic MediaWiki 2.0Released on 4 August 2014 and compatible with MW 1.19.0 - 1.24.x. and starting with Semantic MediaWiki 2.3.0Released on 29 October 2015 and compatible with MW 1.19.0 - 1.25.x. RDF databases are regarded to be equally usable as SQL databases.3

See the help page on Using SPARQL and RDF stores for information on how to make use of this.

Further resources

(Wikidata Q54871).