Slideshare.net (beta)

 
Post: 
Myspace Hi5 Friendster Xanga LiveJournal Facebook Blogger Tagged Typepad Freewebs BlackPlanet gigya icons



All comments

Add a comment on Slide 1

If you have a SlideShare account, login to comment; else you can comment as a guest


Showing 1-50 of 6 (more)

SPARQL in a nutshell

From fabien_gandon, 6 months ago

Tutorial on SPARQL

1280 views  |  2 comments  |  4 favorites  |  70 downloads  |  1 embed (Stats)
 

Groups/Events

 
 

Privacy InfoNew!

This slideshow is Public

 
CC Attribution License
Embed in your blog
Embed (wordpress.com)
custom

Slideshow Statistics
Total Views: 1280
on Slideshare: 1273
from embeds: 7* * Views from embeds since 21 Aug, 07

Slideshow transcript

Slide 1: SPARQL in a nutshell fabien, gandon, inria

Slide 2: RDF triple model is the first layer of the semantic web standards 2

Slide 3: SPARQL on top... an RDF query language and data access protocol 3

Slide 4: SPARQL stands for SPARQL Protocol and RDF Query Language 4

Slide 5: SPARQL in 3 parts part 1: query language part 2: result format part 3: access protocol 5

Slide 6: SPARQL query SELECT ... FROM ... WHERE { ... } 6

Slide 7: SELECT clause to identify the values to be returned 7

Slide 8: FROM clause to identify the data sources to query 8

Slide 9: WHERE clause the triple/graph pattern to be matched against the triples/graphs of RDF 9

Slide 10: WHERE clause a conjunction of triples: { ?x rdf:type ex:Person ?x ex:name ?name } 10

Slide 11: PREFIX to declare the schema used in the query 11

Slide 12: example persons and their names PREFIX ex: <http://inria.fr/schema#> SELECT ?person ?name WHERE { ?person rdf:type ex:Person ?person ex:name ?name . } 12

Slide 13: example of result <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#" > <head> <variable name="person"/> <variable name="name"/> </head> <results ordered="false" distinct="false"> <result> <binding name="person"> <uri>http://inria.fr/schema#fg</uri> </binding> <binding name="name"> <literal>gandon</literal> </binding> </result> <result> ... 13

Slide 14: FILTER to add constraints to the graph pattern (e.g., numerical like X>17 ) 14

Slide 15: example persons at least 18-year old PREFIX ex: <http://inria.fr/schema#> SELECT ?person ?name WHERE { ?person rdf:type ex:Person ?person ex:name ?name . ?person ex:age ?age . FILTER (?age > 17) } 15

Slide 16: FILTER can use many operators, functions (e.g., regular expressions), and even users' extensions 16

Slide 17: OPTIONAL to make the matching of a part of the pattern optional 17

Slide 18: example retrieve the age if available PREFIX ex: <http://inria.fr/schema#> SELECT ?person ?name ?age WHERE { ?person rdf:type ex:Person ?person ex:name ?name . OPTIONAL { ?person ex:age ?age } } 18

Slide 19: UNION to give alternative patterns in a query 19

Slide 20: example explicit or implicit adults PREFIX ex: <http://inria.fr/schema#> SELECT ?name WHERE { ?person ex:name ?name . { { ?person rdf:type ex:Adult } UNION { ?person ex:age ?age FILTER (?age > 17) } } } 20

Slide 21: Sequence & modify ORDER BY to sort LIMIT result number OFFSET rank of first result 21

Slide 22: example results 21 to 40 ordered by name PREFIX ex: <http://inria.fr/schema#> SELECT ?person ?name WHERE { ?person rdf:type ex:Person ?person ex:name ?name . } ORDER BY ?name LIMIT 20 OFFSET 20 22

Slide 23: UNBOUND test a variable is not bound ; used for negation as failure 23

Slide 24: example persons who are not known authors PREFIX ex: <http://inria.fr/schema#> SELECT ?name WHERE { ?person ex:name ?name . OPTIONAL { ?person ex:author ?x } FILTER ( ! bound(?x)) } 24

Slide 25: negation is tricky and errors can easily be made. 25

Slide 26: PREFIX ex: <http://inria.fr/schema#> SELECT ?name WHERE { ?person ex:name ?name . ?person ex:knows ?x FILTER ( ?x != "Java" ) } ? does this find persons who do not know "java" ? 26

Slide 27: ! NO! also persons who know something else PREFIX ex: <http://inria.fr/schema#> SELECT ?name WHERE { ?person ex:name ?name . ?person ex:knows ?x FILTER ( ?x != "Java" ) } fabien ex:knows "Java" fabien ex:knows "C++" fabien is a answer... 27

Slide 28: persons who are not known to know YES! "java" ... negation of an option... PREFIX ex: <http://inria.fr/schema#> SELECT ?name WHERE { ?person ex:name ?name . OPTIONAL { ?person ex:knows ?x FILTER ( ?x = "Java" ) } FILTER ( ! bound(?x) ) } 28

Slide 29: ASK to check just if there is at least one answer ; result is "true" or "false" 29

Slide 30: example is there a person older than 17 ? PREFIX ex: <http://inria.fr/schema#> ASK { ?person ex:age ?age FILTER (?age > 17) } 30

Slide 31: CONSTRUCT return a specific RDF graph for each result 31

Slide 32: example return instances of adults for persons older than 17 PREFIX ex: <http://inria.fr/schema#> CONSTRUCT { ?person rdf:type ex:Adult } WHERE { ?person ex:age ?age FILTER (?age > 17) } 32

Slide 33: SPARQL protocol sending queries and their results accross the web 33

Slide 34: example with HTTP Binding GET /sparql/?query=<encoded query> HTTP/1.1 Host: www.inria.fr User-agent: my-sparql-client/0.1 34

Slide 35: example with SOAP Binding <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <query-request xmlns="http://www.w3.org/2005/09/sparql- protocol-types/#"> <query>SELECT ?x ?p ?y WHERE {?x ?p ?y}</query> </query-request> </soapenv:Body> </soapenv:Envelope> 35

Slide 36: Take-away summary of SPARQL 36

Slide 37: SPARQL is... ... a query language ... ... a result format ... ... an access protocol ... ... for RDF 37

Slide 38: SPARQL query language based on the triple model ?x ?p ?y filters to add constraints optional parts and alternative parts 38

Slide 39: fabien, gandon 39