SPARQL - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

SPARQL

Description:

name Tim Bray /name mbox tb_at_eg.com /mbox /Person Person ... name Tim Bray /name mbox Tim.Bray_at_eg.Com /mbox address Country Canada /Country ... – PowerPoint PPT presentation

Number of Views:102
Avg rating:3.0/5.0
Slides: 38
Provided by: aemra
Category:
Tags: sparql | bray

less

Transcript and Presenter's Notes

Title: SPARQL


1
SPARQL
  • A. Emrah Sanön

2
RDF
  • RDF is quite committed to Semantic Web.
  • Data model
  • Serialization by means of XML
  • Formal semantics
  • Still something is missing!
  • A standard query language.
  • A way for the queries and their respective
    results to be transported between applications /
    services.

3
result
  • SPARQL

4
What is SPARQL
  • Simple Protocol and RDF Query Language
  • Sparkle /'spär-kl/
  • A Protocol
  • A standard RDF Query Language (QL)

5
SPARQL as a Protocol
  • GET /sparql/?queryEncodedQuerydefault-graph-uri
    http//my.example/publishersnamed-graph-uriht
    tp//my.example/bobnamed-graph-urihttp//my.exa
    mple/aliceHTTP/1.1Host my.exampleUser-agent
    sparql-client/0.1

6
SPARQL as a Protocol
  • A way of communication between parties that run
    SPARQL queries.
  • Defining a way of invoking the service.
  • Bindings of a transport protocol for that goal.

7
SPARQL Protocol (1)
  • WSDL description file
  • Description of the protocol.
  • Not for human understanding.
  • HTTP binding
  • Specify how to encode SPARQL queries in URLs with
    GET and POST methods.
  • SOAP binding
  • Specify the SOAP message format (XML message
    exchange format for queries)

8
WSDL Description file
  • WSDL description file (HTTP binding part)
  • ltbinding name"queryHttp" interface"tnsSparqlQue
    ry
  • gt
  • ltfault name"MalformedQuery" whttpzode"400"/gt
  • lt!-- the GET binding for query operation --gt
  • ltoperation ref"tnsquery" whttpmethod"GET"
  • whttpinputSerialization" /gt
  • lt/bindinggt

9
SPARQL Protocol (2)
  • Interface SparqlQuery
  • Only one operation query
  • For transferring string query
  • Data types via XML schema
  • Bindings HTTP / SOAP binding for invokable
    operations.
  • A service must support SparqlQuery interface
  • support the bindings as described in the WSDL.

10
SPARQL Protocol Examples
  • Examples after we cover SPARQL Query Language for
    RDF.

11
SPARQL Query Language
  • A standard query language in the form of
    expressive query against the RDF data model
  • Data access language
  • Graph patterns
  • Powerful than XML queries in some aspects

12
SPARQL Query Language (1)
  • SQL
  • Internals of DB (tables, fields, data, meaning)
  • Impossible to query databases on the WILD WILD
    WEB.
  • So, what does SPARQL propose?
  • URIs.
  • Querying databases globally.
  • Combining data globally.
  • Value of data grows exponentially with the ways
    you combine it.

13
The Wild Wild Web
  • SQL SPARQL
  • XML

14
SPARQL Query Language (2)
  • Data structure definitions are being developed
    worldwide in a distributed manner.
  • Common ontologies (Dublin Core, Foaf, DOAP, etc.)
  • A database publishes the ontologies it exports to
  • An application queries it using those ontologies.

15
Power of SPARQL Illustrated
  • Ask fotograf.com if it has a picture which
    matches some constraints such as title, date,
    size, and some other tag
  • Then ask google for URLs in relation to the tag
    we specified.
  • And turn the results of these two uncoordinated
    data as an RSS feed on your site.
  • All this in just two-three SPARQL queries.

16
Power of SPARQL (2)
  • Ask music cds of price less than 10
  • You can run this query against hepsiburada.com,
    amazon, e-bay, gittigidiyor.com or any other
    seller on earth who has a website and a database.
  • No seller needs to change their databases.
  • Seller needs Conversion layer between ontologies
    and database.
  • Client needs connectivity framework (like JDBC)
    for java.

17
Power of SPARQL (2) Imp.
  • PREFIX dc lthttp//purl.org/dc/elements/1.1/gt
    PREFIX ns lthttp//example.org/nsgt
  • SELECT ?title ?price WHERE ?x nsprice
    ?price . FILTER (?price lt 10) . ?x dctitle
    ?title .

18
SPARQL Syntax -brief-1
  • URIs
  • ltURIgt in lt gt
  • or _at_PREFIX prefix lthttp//....gt
  • prefixname for full URI
  • Literals
  • Literal or Literal_at_language
  • Blank Node
  • _name or for a Blank Node used just once

19
SPARQL Syntax -brief-2
  • Triples and .
  • x y z . t q s .
  • Common predicate and subject
  • x y z, t .which is the same as x y z . x
    y t .
  • Common subject
  • RDF Collections
  • x y ( z t q s )which is short for many
    triples (as lists in LISP)

20
A walkthrough example illustrating the power of
SPARQL
XML/SQL SPARQL
21
Walkthrough example (1xml)
  • ltPersongt ltnamegtHenry Storylt/namegt
    ltmboxgths_at_bblfish.netlt/mboxgt ltknowsgt ltPersongt
    ltnamegtTim Braylt/namegt ltmboxgttb_at_eg.comlt/mboxgt
  • lt/Persongt ltPersongt ltnamegtJonathan
    Storylt/namegt ltmboxgtjs_at_eg.edult/mboxgt
  • lt/Persongt lt/knowsgt
  • lt/Persongt

22
Walkthrough example (1sparql)
  • a Person
  • name "Henry Story"
  • mbox ltmailtohs_at_insead.edugt knows a
    Person name "Tim Bray" mbox
    ltmailtotb_at_eg.com knows a Person
    name "Jonathan Story" mbox
    ltmailtojs_at_eg.edugt .

23
Graph representation
24
Walkthrough example (2)
  • ltAddressBookgtltPersongt ltnamegtJonathan
    Storylt/namegt ltmboxgtJonathan.Story_at_eg.edult/mboxgt
    ltaddressgt ltCountrygtFrancelt/Countrygt
  • lt/addressgt
  • lt/Persongt
  • ltPersongt
  • ltnamegtTim Braylt/namegt ltmboxgtTim.Bray_at_eg.Comlt/mb
    oxgt
  • ltaddressgt ltCountrygtCanadalt/Countrygt
  • lt/addressgt
  • lt/Persongt
  • lt/AddressBookgt

25
Walkthrough example (2sparql)
  • a Person
  • name "Tim Bray"
  • mbox ltmailtoTim.Bray_at_eg.comgt
  • address a Address
  • country "Canada"_at_en .
  • a Person
  • name "Jonathan Story"
  • mbox ltmailtoJonathan.Story_at_eg.edugt address
  • a Address
  • country "France"_at_en
  • .

26
Graph representation
27
Walkthrough example (2)
  • These graphs can be merged into the following
    graph especially if the mbox relation is stated
    as being inverse functional

28
Graph representation(merged)
29
Walkthrough example (2)
  • "Who does Henry know who lives in Canada, and
    what is their e-mail address?"
  • Can only be answered by aggregating data from
    both documents.
  • Can not be done using the XML query languages,
    which can only work on the surface of the
    document.

30
Walkthrough example (2sparql)
  • SELECT ?name ?mail
  • WHERE
  • a Person
  • name "Henry Story"
  • knows name ?name
  • mbox ?mail
  • address a Address country
    "Canada"_at_en
  • .

31
Walkthrough example (3sparql)
  • Names and websites of contributors to PlanetRDF
  • PREFIX foaf lthttp//xmlns.com/foaf/0.1/gt SELECT
    ?name ?website
  • FROM lthttp//planetrdf.com/bloggers.rdfgt WHERE
  • ?person foafweblog ?website
  • foafname ?name .
  • ?website a foafDocument

32
Protocol Example (1)
  • PREFIX foaf lthttp//xmlns.com/foaf/0.1/gt
  • PREFIX dc lthttp//purl.org/dc/elements/1.1/gt
  • SELECT ?who ?g ?mbox
  • FROM lthttp//my.example/publishersgt
  • FROM NAMED lthttp//my.example/alicegt
  • FROM NAMED lthttp//my.example/bobgt
  • WHERE
  • ?g dcpublisher ?who .
  • GRAPH ?g ?x foafmbox ?mbox

33
Protocol Example (1)
  • HTTP/1.1 200 OK
  • Date Wed, 27 Dec 2005 124825 GMT
  • Server Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3
  • Connection closeContent-Type application/sparql-
    resultsxml charsetutf-8
  • lt?xml version"1.0"?gt
  • ltsparql xmlns"gt
  • lt/sparqlgt

34
References
  • http//www.w3.org/2004/Talks/17Dec-sparql/intro/al
    l.html
  • http//jena.sourceforge.net/ARQ/Tutorial/
  • http//blogs.sun.com/roller/page/bblfish
  • http//xmlarmyknife.org/api/rdf/sparql
  • http//xml.com/lpt/a/2005/11/16/introducing-sparql
    -querying-semantic-web-tutorial.html
  • http//www.w3.org/2005/Talks/12May-SPARQL/all.html

35
References (2)
  • http//www-128.ibm.com/developerworks/xml/library/
    j-sparql/
  • http//www.w3.org/TR/rdf-sparql-protocol/
  • http//www.w3.org/2004/Talks/17Dec-sparql/intro/ex
    1.rq
  • http//www.oreillynet.com/pub/wlg/7823

36
Thank you
  • For your attendance
  • and patience

37
Any Questions?
Write a Comment
User Comments (0)
About PowerShow.com