SPARQL

Created on Feb. 23, 2013, 9:02 a.m. by Hevok & updated by Hevok on May 2, 2013, 5:18 p.m.

SPARQL is the Query Language in the Semantic Web which is able to retrieve and manipulate data stored in Resource Description Framework (RDF) Format. It is one of the key technologies of the Semantic Web. In the Semantic Web Technology Stack SPARQL covers everything from from RDF over RDF Schema (RDFS) and one can here ask a RDF(S) database and generate answers with the help of the simple SPARQL.

How to query RDF(S)? SPARQL RDFS is for information exchange and modeling Facts. With the help of RDS one can invent, describe and define models of worlds of Facts, Classes and Relations. This data can be accessed with SPARQL.

SPARQL allows for a Query to consist of Triple Patterns, Conjunctions, Disjunctions, and Optional Patterns [http://www.xml.org/xml/news/archives/archive.10062006.shtml/5]." style="color: #CC0000">SPARQL allows for a Query to consist of Triple Patterns, Conjunctions, Disjunctions, and Optional Patterns [http://www.xml.org/xml/news/archives/archive.10062006.shtml 5].

SPARQL is based on RDF Turtle Serialization.

There exists implementations for multiple Programming Languages [http://www.w3.org/wiki/SparqlImplementations]. Also there are tools that allow one to connect and semi-automatically construct a SPARQL Query for a SPARQL Endpoint (e.g. ViziQuer). Additionally, there exists tools that translate SPARQL Queries to other Query Languages, for example to SQL.

A Query Language for RDF

  • How do we access the knowledge from RDF/RDFS Knowledge Bases?
  • Manual Parsing/Reading and Combination of RDF-Triples is complex
  • Can you imagine a Relational Database without SQL?

First of all we need some Language or some Method to have access to the Knowledge of RDF and RDFS Knowledge Bases. Doing this by hand or simple by program with a parser it is tendentious task because combinations of RDF Triples are really difficult to read and to write of course. It is the same as for the case in Databases where one has a pretty simple Language to excess Data, namely SQL. In accordance to that one has defined an Access and Manipulation Language for Knowledge Bases based on RDF data, which is SPARQL. SPARQL (pronounced as "sparkle") itself is the recursive Acronym for SPARQL Protocol And RDF Query Language and is not only s Query Language but is more. First of all, there is the SPARQL Query Language for RDF Graph Traversal as RDF Facts build together and form Sets of Statements which build overall some kind of Graph. To access this Graph one can use this Query Language. On the other hand SPARQL defines some kind of a Protocol which means the Protocol on top of Http on how to access and how to Query a SPARQL Endpoint. In the end one need some responds from the RDF Database. Therefore, some specific XML Output Format Specification for SPARQL is also part of the SPARQL Definition. SPARQL itself is a W3C Standard since January 2008 and is deeply inspired by the Database Query Language SQL.

SPARQL comes in two versions. SPARQL 1.0 is the recommended Standard and a new Standard is in preparation. With SPARQL one can of course extract Data from a Knowledge Base, data in the sense of URIs, Blank Nodes, typed or untyped Literals and also entire RDF Subgraphs. With SPARQL one can explore a Data Graph and also retrieve Data by a Query that has unknown Relations. On the other hand one can execute complex JOIN operations on Heterogeneous Databases in a single Query. Of course it also gives the possibility to transform RDF Data from one Vocabulary into another. In the end one can also generate new RDF Graphs based on already existing RDF Query Graphs.

SPARQL 1.1 standard is in progress, so the Definition on its way. There are additional Query Features like, for example, some Aggregations Functions, one is allowed to make Subqueries, one is allowed to put Negations into the Queries, there are also some complex project expressions and Property Path. SPARQL 1.1. enables some logical Entailment, because RDF and RDFS are based on Logical Foundations and therefore Entailment is a rather important thing as one can deduce now Facts from already existing Facts. It does already support it for RDF(S), OWL and RDF-Based Semantics. On the other hand SPARQL 1.1. enables SPARQL to be a full Data Manipulation Language, because only there also update of the RDF Graph is allowed, while in the previous version SPARQL only Query not manipulating a Graph is allowed. Graph Manipulation comes with 1.1. Besides Updating an RDF Graph also Information Discovery and Federated Queries are Subject to the new Standard.

learning_sparql.jpg

Tags: query, semantics, manipulation, language, graph, database, data
Categories: Tutorial
Parent: Resource Description Framework
Children: 3-Valued Logic, Blank Nodes in SPARQL Queries, FILTER, Graph Construction, Graph Pattern, Named Graph, NEGATION, Operator, OPTIONAL, Prefix, Queries, SELECT, SPARQL 1.1, SPARQL Endpoint, SPARQL Protocol, SPARQL Query Format, SPARQL Result Format, Unary Operator, UNION

Update entry (Admin) | See changes

Comment on This Data Unit