sparql1 - · pdf fileremove the results of pat2 from the results of pat1 pat1 minus {pat2} 35...
TRANSCRIPT
![Page 2: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/2.jpg)
2
SPARQL 1.1
1. Overview
2. Query
3. Update
4. Protocol (WSDL 2.0)
5. Service Description (as an RDF Graph)
6. Uniform HTTP Protocol for Managing RDF Graphs
7. Entailment Regimes
8. Test Cases
![Page 3: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/3.jpg)
3
Update
Defines an update language for RDF graphs.
![Page 4: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/4.jpg)
4
UpdatePREFIX dc: <http://purl.org/dc/elements/1.1/>
INSERT DATA
{ <http://example/book3> dc:title "A new book" ;
dc:creator "A.N.Other" .
}
![Page 5: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/5.jpg)
5
Update
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
WITH <http://example/addresses>
DELETE { ?person foaf:firstName 'Bill' }
INSERT { ?person foaf:firstName 'William' }
WHERE
{ ?person a foaf:Person .
?person foaf:firstName 'Bill'
}
![Page 6: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/6.jpg)
6
Update
LOAD <documentURI> [ INTO GRAPH <uri> ]
CLEAR [ SILENT ] (GRAPH <uri> | DEFAULT | NAMED | ALL )
CREATE [ SILENT ] GRAPH <uri>
DROP [ SILENT ] (GRAPH <uri> | DEFAULT | NAMED | ALL )
![Page 7: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/7.jpg)
7
Protocol: WSDL 2.0
Defines an abstract interface and HTTP bindings for a protocol to issue SPARQL Query and SPARQL Update statements against a SPARQL endpoint.
It uses WSDL 2.0 to describe a means for conveying SPARQL queries to an SPARQL query processing service and returning the query results to the entity that requested them
![Page 8: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/8.jpg)
8
Service Description: an RDF Graph
Defines a vocabulary and discovery mechanism for describing the capabilities of a SPARQL endpoint accessible by SPARQL Protocol.
SPARQL services made available via the SPARQL Protocol SHOULD return a service description document at the service URL.
![Page 9: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/9.jpg)
9
Service Description
This service description SHOULD be made available in an RDF serialization, and MAY be provided embedded in HTML by RDFa
It is an RDF graph that describes the service (e.g. it’s default graph, named graphs, support for 1.0, 1.1, Update, etc.)
![Page 10: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/10.jpg)
10
HTTP Protocol
Describes the use of the HTTP protocol for managing named RDF graphs on an HTTP server.
Binding of PUT, GET, POST, etc.
![Page 11: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/11.jpg)
11
Entailment Regime
Defines conditions under which SPARQL queries can be used with entailment regimes such as RDF, RDF Schema, OWL, or RIF.
![Page 12: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/12.jpg)
12
SPARQL 1.1 Query Language
Project Expression
Aggregates
Property Path
New statements
Minus, Exists
Subquery
![Page 13: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/13.jpg)
13
Project Expression
Return the result of an expression
select * (ext:price(?doc) as ?price)
where {
?x rdf:type c:Document
?x c:author ?a
}
![Page 14: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/14.jpg)
14
New filters
coalesce(?x, ?y, 10): return first value that is not an error (such as unbound)
if(?x>10, ?y , ?x+10)
?x in (“alpha”, ?beta, ‘gamma’)
uri(), iri(): create an uri
![Page 15: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/15.jpg)
15
New functions
strdt(“12”, xsd:integer): create a literal with a datatype
strlang(“human”, “en”): create a literal with a language tag
bnode() bnode(“id314”) : create a blank node
![Page 16: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/16.jpg)
16
Aggregates
select ?x (count(?doc) as ?count) where {
?x c:hasCreated ?doc
}
group by ?x
![Page 17: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/17.jpg)
17
Group by
Several arguments
select ?x ?date (count(?doc) as ?count) where {
?x c:hasCreated ?doc
?doc c:date ?date
}
group by ?x ?date
![Page 18: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/18.jpg)
18
Group by + count + order
select ?x (count(?doc) as ?count) where {
?x c:hasCreated ?doc
}
group by ?x
order by desc (count(?doc))
![Page 19: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/19.jpg)
19
Having
Additional filter after aggregate
select ?x (count(?doc) as ?count) where {
?x c:hasCreated ?doc
}
group by ?x
having (count(?doc) >= 10)
![Page 20: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/20.jpg)
20
Aggregates
min, max, count
sum, avg
group_concat, sample
![Page 21: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/21.jpg)
21
Aggregates
Return one result when there is no group by
select (min(?price) as ?min) where {
?x ex:price ?price
}
![Page 22: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/22.jpg)
22
Aggregates
Count the number of results
select (count(*) as ?count) where {
?x ex:price ?price
}
![Page 23: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/23.jpg)
23
Aggregates
Count number of distinct values
select (count(distinct ?x) as ?count) where {
?x ex:price ?price
}
![Page 24: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/24.jpg)
24
Exercise
Find the number of persons member of an organization and who are not author of any document
Find in which organization there is the most persons that are not author of any document
![Page 25: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/25.jpg)
25
Exercise
select * (count(?x) as ?count)
where {
?x ex:member ?org
filter(?org = <O>)
optional {?x ex:author ?doc}
filter(!bound(?doc))
}
group by ?org
![Page 26: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/26.jpg)
26
Exercise
select * (count(?x) as ?count)
where {
?x ex:member ?org
optional {?x ex:author ?doc}
filter(!bound(?doc))
}
group by ?org
order by desc(?count)
limit 1
![Page 27: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/27.jpg)
27
Property Path
Path of length more than one between resources
xxx member yyy include zzz author ttt
select * where {
xxx member/include/author ttt
}
![Page 28: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/28.jpg)
28
Property Path
xxx rdf:first aaa
xxx rdf:rest yyy rdf:first bbb
xxx rdf:rest yyy rdf:rest zzz rdf:first ccc
Zero or more rest followed by one first : rest* first
select ?val where {
xxx rdf:rest*/rdf:first ?val
}
![Page 29: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/29.jpg)
29
Property Path Expression Operators
/ : sequence
| : alternative
+ : one or several
* : zero or several
? : optional
^ : inverse
! : negation
{min,max} : variable length path
![Page 30: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/30.jpg)
30
Property Path: Reverse
?x ^ex:prop ?y ::=
?y ex:prop ?x
?x ^EXP ?y ::=
?y EXP ?x
![Page 31: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/31.jpg)
31
Property Path: Negation
?x ! ex:prop ?y
All properties but ex:prop
![Page 32: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/32.jpg)
32
Property Path: Variable length
?x rdfs:subClassOf{1,5} ?y
?x rdfs:subClassOf{,5} ?y
?x rdfs:subClassOf{1,} ?y
?x rdfs:subClassOf{5} ?y
![Page 33: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/33.jpg)
33
Negation
Two patterns:
Minus
Not Exists
![Page 34: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/34.jpg)
34
MINUS
Remove the results of PAT2 from the results
of PAT1
PAT1 minus {PAT2}
![Page 35: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/35.jpg)
35
MINUS
Remove from the member of org the
resources whose name is ‘Olivier’
select * where {
?x c:memberOf ?org
minus {?x c:name ‘Olivier’}
}
![Page 36: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/36.jpg)
36
MINUS
PAT1 minus {PAT2}
Remove results that are compatible: same variables have
same values
when there is at least one common variable
![Page 37: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/37.jpg)
37
MINUS: remove nothing
select * where {
?x c:memberOf ?org
minus {?y c:name ‘Olivier’}
}
Remove results that are compatible (same variables have
same values) when there is at least one common
variable
![Page 38: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/38.jpg)
38
(NOT) EXISTS
Test (absence) presence of pattern in RDF
Graph
PAT1 . filter(! exists {PAT2})
![Page 39: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/39.jpg)
39
NOT EXISTS
?x c:memberOf ?org .
filter(! exists {?x c:author ?doc })
![Page 40: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/40.jpg)
40
Minus vs Exists
Same results:
?x c:memberOf ?org .
filter(! exists {?x c:author ?doc })
?x c:memberOf ?org .
minus {?x c:author ?doc }
![Page 41: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/41.jpg)
41
Minus vs Exists
Different results:
?x c:memberOf ?org .
filter(! exists {?y c:author ?doc })
?x c:memberOf ?org .
minus {?y c:author ?doc }
![Page 42: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/42.jpg)
42
Quiz
?x c:memberOf ?org .
minus {ex:a c:memberOf ex:b}
Does it return:
ex:a c:memberOf ex:b
![Page 43: SPARQL1 - · PDF fileRemove the results of PAT2 from the results of PAT1 PAT1 minus {PAT2} 35 MINUS Remove from the member of org the ... 10/6/2010 10:55:15 AM](https://reader031.vdocuments.us/reader031/viewer/2022022002/5a85e9317f8b9a9f1b8cc24b/html5/thumbnails/43.jpg)
43
Sub Query: Nested Query
Find properties of the cheapest car
select * where {
{select (min(?price) as ?min) where {
?car ex:hasPrice ?price}
}
?car ex:hasPrice ?min
?car ?p ?val
}