Querying – SPARQL

Petr Kˇremen

[email protected]

October 19, 2017

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 1 / 26 Outline

1 Querying Semantic Web – SPARQL SPARQL Query Language

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 2 / 26 Querying Semantic Web – SPARQL

1 Querying Semantic Web – SPARQL SPARQL Query Language

Querying Semantic Web – SPARQL

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 3 / 26 actions (ask, assert, fwrule), answers (bindings for vars, proof RDF triples)

“XPath for RDF” forward/backward traversal, filtering, but no support for restructuring/constructing queries.

reactive-rule language Algea (see http://www.w3.org/2001/Annotea)

path-based language Versa (see http://4suite.org)

. . . , there are plenty of them, but today SPARQL wins.

Querying Semantic Web – SPARQL History of RDF Query Languages

relational-based – SPARQL, RQL, TRIPLE, Xcerpt, SeRQL

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 3 / 26 “XPath for RDF” forward/backward traversal, filtering, but no support for restructuring/constructing queries.

actions (ask, assert, fwrule), answers (bindings for vars, proof RDF triples) path-based language Versa (see http://4suite.org)

. . . , there are plenty of them, but today SPARQL wins.

Querying Semantic Web – SPARQL History of RDF Query Languages

relational-based – SPARQL, RQL, TRIPLE, Xcerpt, SeRQL reactive-rule language Algea (see http://www.w3.org/2001/Annotea)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 3 / 26 “XPath for RDF” forward/backward traversal, filtering, but no support for restructuring/constructing queries.

path-based language Versa (see http://4suite.org)

. . . , there are plenty of them, but today SPARQL wins.

Querying Semantic Web – SPARQL History of RDF Query Languages

relational-based – SPARQL, RQL, TRIPLE, Xcerpt, SeRQL reactive-rule language Algea (see http://www.w3.org/2001/Annotea) actions (ask, assert, fwrule), answers (bindings for vars, proof RDF triples)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 3 / 26 “XPath for RDF” forward/backward traversal, filtering, but no support for restructuring/constructing queries. . . . , there are plenty of them, but today SPARQL wins.

Querying Semantic Web – SPARQL History of RDF Query Languages

relational-based – SPARQL, RQL, TRIPLE, Xcerpt, SeRQL reactive-rule language Algea (see http://www.w3.org/2001/Annotea) actions (ask, assert, fwrule), answers (bindings for vars, proof RDF triples) path-based language Versa (see http://4suite.org)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 3 / 26 forward/backward traversal, filtering, but no support for restructuring/constructing queries. . . . , there are plenty of them, but today SPARQL wins.

Querying Semantic Web – SPARQL History of RDF Query Languages

relational-based – SPARQL, RQL, TRIPLE, Xcerpt, SeRQL reactive-rule language Algea (see http://www.w3.org/2001/Annotea) actions (ask, assert, fwrule), answers (bindings for vars, proof RDF triples) path-based language Versa (see http://4suite.org) “XPath for RDF”

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 3 / 26 . . . , there are plenty of them, but today SPARQL wins.

Querying Semantic Web – SPARQL History of RDF Query Languages

relational-based – SPARQL, RQL, TRIPLE, Xcerpt, SeRQL reactive-rule language Algea (see http://www.w3.org/2001/Annotea) actions (ask, assert, fwrule), answers (bindings for vars, proof RDF triples) path-based language Versa (see http://4suite.org) “XPath for RDF” forward/backward traversal, filtering, but no support for restructuring/constructing queries.

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 3 / 26 Querying Semantic Web – SPARQL History of RDF Query Languages

relational-based – SPARQL, RQL, TRIPLE, Xcerpt, SeRQL reactive-rule language Algea (see http://www.w3.org/2001/Annotea) actions (ask, assert, fwrule), answers (bindings for vars, proof RDF triples) path-based language Versa (see http://4suite.org) “XPath for RDF” forward/backward traversal, filtering, but no support for restructuring/constructing queries. . . . , there are plenty of them, but today SPARQL wins.

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 3 / 26 Querying Semantic Web – SPARQL SPARQL vs. SQL

First, let’s shortly compare a query in SQL and SPARQL. ’Get projects having male administrators starting on the letter N’

SELECT e.surname AS es, PREFIX : p.name AS pn SELECT ?sn,(?projname AS ?pn) FROM employee e, project p WHERE { WHERE e.gender= 'male' ?e a :Employee . AND p.administratorId= e.id ?e: surname ?sn. AND e.surname LIKE 'N\%'; ?e: gender 'male'. ?p a :Project . ?p: name ?pn. ?p: administrator ? e. FILTER (strstarts(?sn,'N')) }

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 4 / 26 a “data definition language” (SPARQL 1.1. Update language) definition of SPARQL services (protocol over HTTP, graph management HTTP protocol), semantic description, an extension for executing distributed queries over more SPARQL endpoints [Aranda:13:SFQ] JSON, CSV, TSV, XML query result formats [Seaborne:13:SQR] definition of entailment regimes for RDF extensions (e.g. OWL, see the respective lecture) [Ogbuji:13:SER].

Querying Semantic Web – SPARQL SPARQL Factsheet

SPARQL 1.1 was standardized as a set of 12 W3C Recommendations on 21 March 2013, covering a query language (SPARQL 1.1 Query Language) [Harris:13:SQL]

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 5 / 26 definition of SPARQL services (protocol over HTTP, graph management HTTP protocol), semantic description, an extension for executing distributed queries over more SPARQL endpoints [Aranda:13:SFQ] JSON, CSV, TSV, XML query result formats [Seaborne:13:SQR] definition of entailment regimes for RDF extensions (e.g. OWL, see the respective lecture) [Ogbuji:13:SER].

Querying Semantic Web – SPARQL SPARQL Factsheet

SPARQL 1.1 was standardized as a set of 12 W3C Recommendations on 21 March 2013, covering a query language (SPARQL 1.1 Query Language) [Harris:13:SQL] a “data definition language” (SPARQL 1.1. Update language)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 5 / 26 an extension for executing distributed queries over more SPARQL endpoints [Aranda:13:SFQ] JSON, CSV, TSV, XML query result formats [Seaborne:13:SQR] definition of entailment regimes for RDF extensions (e.g. OWL, see the respective lecture) [Ogbuji:13:SER].

Querying Semantic Web – SPARQL SPARQL Factsheet

SPARQL 1.1 was standardized as a set of 12 W3C Recommendations on 21 March 2013, covering a query language (SPARQL 1.1 Query Language) [Harris:13:SQL] a “data definition language” (SPARQL 1.1. Update language) definition of SPARQL services (protocol over HTTP, graph management HTTP protocol), semantic description,

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 5 / 26 JSON, CSV, TSV, XML query result formats [Seaborne:13:SQR] definition of entailment regimes for RDF extensions (e.g. OWL, see the respective lecture) [Ogbuji:13:SER].

Querying Semantic Web – SPARQL SPARQL Factsheet

SPARQL 1.1 was standardized as a set of 12 W3C Recommendations on 21 March 2013, covering a query language (SPARQL 1.1 Query Language) [Harris:13:SQL] a “data definition language” (SPARQL 1.1. Update language) definition of SPARQL services (protocol over HTTP, graph management HTTP protocol), semantic description, an extension for executing distributed queries over more SPARQL endpoints [Aranda:13:SFQ]

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 5 / 26 definition of entailment regimes for RDF extensions (e.g. OWL, see the respective lecture) [Ogbuji:13:SER].

Querying Semantic Web – SPARQL SPARQL Factsheet

SPARQL 1.1 was standardized as a set of 12 W3C Recommendations on 21 March 2013, covering a query language (SPARQL 1.1 Query Language) [Harris:13:SQL] a “data definition language” (SPARQL 1.1. Update language) definition of SPARQL services (protocol over HTTP, graph management HTTP protocol), semantic description, an extension for executing distributed queries over more SPARQL endpoints [Aranda:13:SFQ] JSON, CSV, TSV, XML query result formats [Seaborne:13:SQR]

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 5 / 26 Querying Semantic Web – SPARQL SPARQL Factsheet

SPARQL 1.1 was standardized as a set of 12 W3C Recommendations on 21 March 2013, covering a query language (SPARQL 1.1 Query Language) [Harris:13:SQL] a “data definition language” (SPARQL 1.1. Update language) definition of SPARQL services (protocol over HTTP, graph management HTTP protocol), semantic description, an extension for executing distributed queries over more SPARQL endpoints [Aranda:13:SFQ] JSON, CSV, TSV, XML query result formats [Seaborne:13:SQR] definition of entailment regimes for RDF extensions (e.g. OWL, see the respective lecture) [Ogbuji:13:SER].

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 5 / 26 Querying Semantic Web – SPARQL SPARQL Query Language

SPARQL Query Language

1 Querying Semantic Web – SPARQL SPARQL Query Language

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 6 / 26 ASK – returns a true/false indicating existence of the given pattern in the RDF graph CONSTRUCT – returns an RDF graph constructed from the binding table DESCRIBE – returns an RDF graph describing the given resource ( not fixed)

Querying Semantic Web – SPARQL SPARQL Query Language Query Types

SELECT – returns a binding table (similarly to SQL)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 7 / 26 CONSTRUCT – returns an RDF graph constructed from the binding table DESCRIBE – returns an RDF graph describing the given resource (semantics not fixed)

Querying Semantic Web – SPARQL SPARQL Query Language Query Types

SELECT – returns a binding table (similarly to SQL) ASK – returns a true/false indicating existence of the given pattern in the RDF graph

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 7 / 26 DESCRIBE – returns an RDF graph describing the given resource (semantics not fixed)

Querying Semantic Web – SPARQL SPARQL Query Language Query Types

SELECT – returns a binding table (similarly to SQL) ASK – returns a true/false indicating existence of the given pattern in the RDF graph CONSTRUCT – returns an RDF graph constructed from the binding table

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 7 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Query Types

SELECT – returns a binding table (similarly to SQL) ASK – returns a true/false indicating existence of the given pattern in the RDF graph CONSTRUCT – returns an RDF graph constructed from the binding table DESCRIBE – returns an RDF graph describing the given resource (semantics not fixed)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 7 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Query Evaluation

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 8 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Basic Definitions

RDF Term is an element of the set of RDF terms T = TI ∪ TB ∪ TL, being a union of set of all IRIs, blank nodes and literals respectively. graph store is a mutable container providing an RDF dataset at each time, solution is a mapping µ : V → T assigning an RDF term to each variable from the query,

result set is a list R = (µ1, . . . , µn) of solutions,

triple pattern (TP) is a member of (T ∪ V ) × (TI ∪ V ) × (T ∪ V ),

basic graph pattern (BGP) is a set BGP = {TP1,..., TPn} of triple patterns.

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 9 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Graph Patterns – Overview

Graph patterns cover all basic algebraic operations: conjunction (sequence of graph patterns), disjunction (UNION pattern), negation (FILTER NOT EXISTS, MINUS) conditional conjunction (OPTIONAL)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 10 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Basic Graph Patterns

Repository content: Query with a BGP

@prefix: PREFIX : @prefix r: PREFIX rdfs: @prefix rdfs: ,→ ,→ SELECT ?s ?l :inventors { WHERE { r:Thomas_Edison:invented:bulb . ?s: invented ?i. r:J_Cimrman:invented:bulb . ?i rdfs:label ?l.} :bulb rdfs:label "Bulb"@en , "Zarovka"@cs . :wheel rdfs:label "Wheel"@en . _:x:invented:wheel . _:y:invented:SteamEngine . _:z:invented:Gunpowder . Table: Result set :Gunpowder rdfs:label "Strelny prach"@cs . } s l r:Thomas Edison “Bulb”@en r:J Cimrman “Bulb”@en r:Thomas Edison “Zarovka”@cs r:J Cimrman “Zarovka”@cs :a “Wheel”@en :b “Strelny prach”@cs

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 11 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Filtering results Description syntax BGP1 FILTER(boolean condition) BGP1 description FILTER clause filters BGP results; it can be anywhere in a BGP (does not break it)

Query with a BGP PREFIX : string functions – PREFIX rdfs: e.g. strlen, ,→ SELECT ?s ?l contains, WHERE { substr, ?s: invented ?i. ?i rdfs:label ?l concat, regex, FILTER(regex(?l,"ˆ.ul.*") replace && contains(str(?s),"Cimr")) } RDF term functions – e.g. isIRI, IRI, isBlank, BNODE, Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL isLiteral,October 19, 2017 12 / 26 str, lang, datatype . . . , see SPARQL 1.1 spec. Querying Semantic Web – SPARQL SPARQL Query Language Optional data

Description syntax GP1 OPTIONAL { GP2 } description results of GP1 are optionally augmented with results of GP2, if any. Optionals are left-associative.

Two optionals PREFIX : PREFIX rdfs: Table: Result set ,→ SELECT ?s ?i ?l s l WHERE { r:Thomas Edison “Bulb”@en r:J Cimrman “Bulb”@en ?s: invented ?i. :a “Wheel”@en OPTIONAL { :b ?i rdfs:label ?l FILTER (lang(?l)="en"). :c “Strelny prach”@cs } OPTIONAL { ?i rdfs:label ?l FILTER (lang(?l)="cs") } }

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 13 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Other examples

FILTERing with regular expressions PREFIX dc: SELECT ?title WHERE { ?x dc:title ?title. ?x dc:author ?author FILTER regex(?title, ".SPARQL")}

Order of OPTIONALs might be important PREFIX rdf: PREFIX books: SELECT ?writing ?name WHERE { ?writing rdf:type books:Essay . OPTIONAL { ?writing books:translator ?p. ?p dc:name ?name.}. OPTIONAL { ?writing books:author ?p. ?p dc:name ?name.}}

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 14 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Negation

negation as failure – i.e. what cannot be inferred is considered false. two constructs – MINUS vs. FILTER NOT EXISTS MINUS FILTER NOT EXISTS PREFIX : PREFIX : PREFIX rdfs: PREFIX rdfs: ,→ ,→ SELECT ?s1 ?i SELECT ?s1 ?i { ?s1: invented ?i. { MINUS { ?s1: invented ?i. ?s2: invented ?i. FILTER NOT EXISTS{ FILTER(?s1 != ?s2) . }} ?s2: invented ?i. FILTER(?s1 != ?s2). }} Variable ?s1 is not bound in the MINUS pattern. Returns all Returns all inventions that were inventors. invented just by one inventor.

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 15 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Property Paths

Description Property paths allow to express simple regular expressions on properties, as follows syntax matches (e(i) means path element, p(i) means iri or ˆiri) iri an IRI (path of length 1) ˆe an inverse path (o → s) e1 / e2 a sequence path of e1 followed by e2 e1 | e2 an alternative path of e1 or e2 e∗ a sequence path of zero or more matches of e e+ a sequence path of one or more matches of e e? a sequence path of zero or one more matches of e !(p1| ... |pn) any IRI not matching any of pi (e) group path (brackets for precedence)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 16 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Property Paths – Examples

Get the name of a resource PREFIX dc: PREFIX rdfs: SELECT * { ?s rdfs:label|dc:title ?name. }

Get elements of an RDF collection PREFIX dc: PREFIX rdfs: SELECT * { ?s( rdf:rest*)/rdf:first ?listItem. }

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 17 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Aggregations Description Similarly to SQL, SPARQL allows using aggregation functions for numeric/sting data: COUNT(?var), or COUNT(DISTINCT ?var) – counts number of (distinct) occurences of ?var in the resultset, MIN(?v),MAX(?v),SUM(?v),AVG(?v) – analogous to their SQL counterparts, GROUP CONCAT(?var; separator = ) AS ?group) – concatenates all elements in the group with the given separator character, SAMPLE – takes an arbitrary representative from the group. Usage of (?expr as ?var) alias is obligatory. Similarly to SQL, SPARQL allows computing aggregates over particular data groups and filter in them using GROUP BY/HAVING construct.

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 18 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Aggregation – Examples

Compute the number of inventions of each inventor. PREFIX : PREFIX rdfs: SELECT (COUNT(?s) as ?count) ?i(GROUP_CONCAT(?s;separator=",") as ,→ ?inventors) FROM :inventors WHERE { ?s: invented ?i. } GROUP BY ?i HAVING (COUNT(?s)>1)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 19 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Variable assignment

Description Variables can be assigned results of function (or aggregation function). The syntax is (expr AS ?v), where expr is an expression and ?v is the newly create variable not appearing before.

Compute the number of inventions of each inventor. PREFIX : PREFIX rdfs: SELECT (COUNT(?s) AS ?count) ?invention FROM :inventors WHERE { ?s: invented ?i. ?i rdfs:label ?l BIND (concat("Invention: ",?l) AS ?invention) } GROUP BY ?i ?invention

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 20 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Distributed Queries

Syntax and semantics syntax... SERVICE (SILENT) sparqlServiceURI { GP } semantics this clause poses a query described by graph pattern GP to a remote SPARQL endpoint sparqlServiceURI

DBPedia service query PREFIX : Local repo content PREFIXp : PREFIXr : @prefix : SELECT ?s ?p ?o ?i @prefixp : WHERE { ,→ GRAPH :inventors { ?s: invented ?i.} @prefixr : OPTIONAL { SERVICE SILENT ,→ { :inventors { ?s ?p ?o r:Thomas_Edison :invented :bulb. FILTER( strstarts(str(?p), r:J_Cimrman :invented :bulb. concat(str(p:),"death")) ) }}} }

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 21 / 26 ORDER BY, LIMIT, OFFSET – used analogously to SQL FROM, FROM NAMED – used to specify active default/named graphs for the query SELECT DISTINCT – removes duplicates from the results

Querying Semantic Web – SPARQL SPARQL Query Language Selected Other Features

VALUES – predefined variable bindining specified in the tabular form

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 22 / 26 FROM, FROM NAMED – used to specify active default/named graphs for the query SELECT DISTINCT – removes duplicates from the results

Querying Semantic Web – SPARQL SPARQL Query Language Selected Other Features

VALUES – predefined variable bindining specified in the tabular form ORDER BY, LIMIT, OFFSET – used analogously to SQL

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 22 / 26 SELECT DISTINCT – removes duplicates from the results

Querying Semantic Web – SPARQL SPARQL Query Language Selected Other Features

VALUES – predefined variable bindining specified in the tabular form ORDER BY, LIMIT, OFFSET – used analogously to SQL FROM, FROM NAMED – used to specify active default/named graphs for the query

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 22 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Selected Other Features

VALUES – predefined variable bindining specified in the tabular form ORDER BY, LIMIT, OFFSET – used analogously to SQL FROM, FROM NAMED – used to specify active default/named graphs for the query SELECT DISTINCT – removes duplicates from the results

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 22 / 26 Querying Semantic Web – SPARQL SPARQL Query Language SPARQL Entailment Regimes simply – SPARQL spec. [Harris:13:SQL] defines evaluation of BGPs w.r.t. simple entailment [Ogbuji:13:SER] defines a several other entailment regimes for SPARQL BGPs: RDF entailment, RDFS entailment, D-entailment , as defined in RDF spec. OWL 2 entailments, RIF entailment , that are the much more expressive, see next lecture. ... conditions for defining custom entailment regimes All SPARQL entailment regimes must ensure compliance with the corresponding entailment (e.g. RDF, RDFS) finiteness of results only canonical b-nodes can be returned (ensured by skolemization of both the query and the queried graph), only finite part of respective vocabularies can be returned as query results (e.g. RDF vocabulary without rdf: n properties not occuring Petr Kˇremen ([email protected])in the graph). Querying Semantic Web – SPARQL October 19, 2017 23 / 26 RDF-entailment No result. RDFS-entailment One result: ?x=:a. OWL-entailment Two results: ?x=:a and ?x=:b.

Querying Semantic Web – SPARQL SPARQL Query Language SPARQL Evaluation Semantics

PREFIX : SELECT ?x WHERE { ?x: p :d }

Simple-entailment No result.

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 24 / 26 RDFS-entailment One result: ?x=:a. OWL-entailment Two results: ?x=:a and ?x=:b.

Querying Semantic Web – SPARQL SPARQL Query Language SPARQL Evaluation Semantics

PREFIX : SELECT ?x WHERE { ?x: p :d }

Simple-entailment No result. RDF-entailment No result.

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 24 / 26 OWL-entailment Two results: ?x=:a and ?x=:b.

Querying Semantic Web – SPARQL SPARQL Query Language SPARQL Evaluation Semantics

PREFIX : SELECT ?x WHERE { ?x: p :d }

Simple-entailment No result. RDF-entailment No result. RDFS-entailment One result: ?x=:a.

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 24 / 26 Querying Semantic Web – SPARQL SPARQL Query Language SPARQL Evaluation Semantics

PREFIX : SELECT ?x WHERE { ?x: p :d }

Simple-entailment No result. RDF-entailment No result. RDFS-entailment One result: ?x=:a. OWL-entailment Two results: ?x=:a and ?x=:b.

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 24 / 26 Querying Semantic Web – SPARQL SPARQL Query Language SPARQL SELECT/ASK results

CSV for SELECT; loses { "head":{ information about "vars":[ "person", "name"] datatypes/lan- }, "results":{ guages of RDF "bindings": terms [{ "person":{ TSV for SELECT; is "type": "uri", lossless "value": "http://ex.com/p1" ,→ }, XML, JSON for SELECT,ASK; "name":{ is lossless, supports "type":"literal", "value": "Smith"} additional },{ information (e.g. "person":{ "type": "uri", columns "value": "http://ex.com/p2" identification ,→ } }] through link }, attribute), } Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 25 / 26 iSPARQL – SPARQL visual query builder (http://oat.openlinksw.com/isparql/) SNORQL – Web front-end for exploring SPARQL endpoints (https://github.com/kurtjx/SNORQL) SeRQL – Sesame query language (alternative to SPARQL) SQWRL (Semantic Query-Enhanced Web Rule Language) – query language based on SWRL (see next lecture), http: //protege.cim3.net/cgi-bin/wiki.pl?SQWRL

Querying Semantic Web – SPARQL SPARQL Query Language Related Technologies

SPIN (SPARQL inference notation) – SPARQL rules encoded in RDF (http://spinrdf.org/)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 26 / 26 SNORQL – Web front-end for exploring SPARQL endpoints (https://github.com/kurtjx/SNORQL) SeRQL – Sesame query language (alternative to SPARQL) SQWRL (Semantic Query-Enhanced Web Rule Language) – query language based on SWRL (see next lecture), http: //protege.cim3.net/cgi-bin/wiki.pl?SQWRL

Querying Semantic Web – SPARQL SPARQL Query Language Related Technologies

SPIN (SPARQL inference notation) – SPARQL rules encoded in RDF (http://spinrdf.org/) iSPARQL – SPARQL visual query builder (http://oat.openlinksw.com/isparql/)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 26 / 26 SeRQL – Sesame query language (alternative to SPARQL) SQWRL (Semantic Query-Enhanced Web Rule Language) – query language based on SWRL (see next lecture), http: //protege.cim3.net/cgi-bin/wiki.pl?SQWRL

Querying Semantic Web – SPARQL SPARQL Query Language Related Technologies

SPIN (SPARQL inference notation) – SPARQL rules encoded in RDF (http://spinrdf.org/) iSPARQL – SPARQL visual query builder (http://oat.openlinksw.com/isparql/) SNORQL – Web front-end for exploring SPARQL endpoints (https://github.com/kurtjx/SNORQL)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 26 / 26 SQWRL (Semantic Query-Enhanced Web Rule Language) – query language based on SWRL (see next lecture), http: //protege.cim3.net/cgi-bin/wiki.pl?SQWRL

Querying Semantic Web – SPARQL SPARQL Query Language Related Technologies

SPIN (SPARQL inference notation) – SPARQL rules encoded in RDF (http://spinrdf.org/) iSPARQL – SPARQL visual query builder (http://oat.openlinksw.com/isparql/) SNORQL – Web front-end for exploring SPARQL endpoints (https://github.com/kurtjx/SNORQL) SeRQL – Sesame query language (alternative to SPARQL)

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 26 / 26 Querying Semantic Web – SPARQL SPARQL Query Language Related Technologies

SPIN (SPARQL inference notation) – SPARQL rules encoded in RDF (http://spinrdf.org/) iSPARQL – SPARQL visual query builder (http://oat.openlinksw.com/isparql/) SNORQL – Web front-end for exploring SPARQL endpoints (https://github.com/kurtjx/SNORQL) SeRQL – Sesame query language (alternative to SPARQL) SQWRL (Semantic Query-Enhanced Web Rule Language) – query language based on SWRL (see next lecture), http: //protege.cim3.net/cgi-bin/wiki.pl?SQWRL

Petr Kˇremen ([email protected]) Querying Semantic Web – SPARQL October 19, 2017 26 / 26