To jest stara wersja strony!


Opis

Sławomir Widlarz swidlarz@gmail.pl

SemWeb_SPARQL

* research on SPARQL,
* provide a presentation,
* look for language support
* other tools
* look for/build Prolog API, e.g. SeRQL

Spotkania

20090326

What is SPARQL


Resource Description Framework (RDF) sets a standard for describing metadata in a way that computers can understand and process it, and integrate information from disparate information sources on the Web. RDF has needed a standard query language for some time and having one will make many development tasks much easier. Or how would you feel using relational databases without SQL?

SPARQL (‘sparkle’) is a standardized query language for RDF data. It offers developers of Semantic Web applications a way to write queries across this wide range of information. Used with a common protocol, applications can access and combine information from multiple sources on the Web. For example, SPARQL can be used to write Semantic Web applications in areas like financial markets, tourism, transportation, and pharmaceuticals.

SPARQL, which is both a query language and a data access protocol, has the ability to become a key component in Web 2.0 applications: as a standard backed by a flexible data model, it can provide a common query mechanism for all Web 2.0 applications – just what Web 2.0 needs. As SPARQL emerges, we can expect to see a fast growing number of application developers

Introduction


  • RDF – flexible and extensible way to represent information about WWW resources
  • SPARQL - query language for getting information from RDF graphs. It provides facilities to:
    • extract information in the form of URIs, blank nodes, plain and typed literals.
    • extract RDF subgraphs.
    • construct new RDF graphs based on information in the queried graphs
  • matching graph patterns
  • variables – global scope; indicated by ‘?‘ or ‘$‘
  • query terms – based on Turtle syntax
  • terms delimited by „<>” are relative URI references
  • data description format - Turtle

Graph Patterns

Basic Graph Pattern – set of Triple Patterns

Group Pattern - a set of graph patterns must all match

Value Constraints - restrict RDF terms in a solution

Optional Graph Patterns .- additional patterns may extend the solution

Alternative Graph Pattern – two or more possible patterns are tried

Patterns on Named Graphs - patterns are matched against named graphs

Basic Graph Pattern

  • Set of Triple Patterns
    • Triple Pattern – similar to an RDF Triple (subject, predicate, object), but any component can be a query variable; literal subjects are allowed,
    • Matching a triple pattern to a graph: bindings between variables and RDF Terms.
  • Matching of Basic Graph Patterns
    • A Pattern Solution of Graph Pattern GP on graph G is any substitution S such that S(GP) is a subgraph of G.
   SELECT ?x ?v WHERE { ?x ?x ?v }
   rdf:type rdf:type rdf:Property

Basic Graph Pattern - Multiple Matches

Data:

    @prefix foaf:  <http://xmlns.com/foaf/0.1/> .
    _:a  foaf:name   "Johnny Lee Outlaw" .
    _:a  foaf:mbox   <mailto:jlow@example.com> .
    _:b  foaf:name   "Peter Goodguy" .
    _:b  foaf:mbox   <mailto:peter@example.org> .
    _:c  foaf:mbox   <mailto:carol@example.org> .

Query:

    PREFIX foaf:   <http://xmlns.com/foaf/0.1/>
    SELECT ?name ?mbox
    WHERE
    { ?x foaf:name ?name .
    ?x foaf:mbox ?mbox }

Query Result:

namembox
„Johnny Lee Outlaw”<mailto:jlow@example.com>
„Peter Goodguy” <mailto:peter@example.org>

Basic Graph Pattern - Blank Nodes

Data:

   @prefix foaf:  <http://xmlns.com/foaf/0.1/> .\\
   _:a  foaf:name   "Alice" .\\
   _:b  foaf:name   "Bob" .\\

Query:

   PREFIX foaf:   <http://xmlns.com/foaf/0.1/>\\
   SELECT ?x ?name\\
   WHERE  { ?x foaf:name ?name }\\
xname
_:c„Alice”
_:d„Bob”

Group Pattern

In a SPARQL query string, a group graph pattern is delimited with braces: {}. For example, this query's query pattern is a group graph pattern of one basic graph pattern.

    PREFIX foaf:    <http://xmlns.com/foaf/0.1/> \\
    SELECT ?name ?mbox\\
    WHERE  { 
    ?x foaf:name ?name . 
    ?x foaf:mbox ?mbox .
            } 

The same solutions would be obtained from a query that grouped the triple patterns into two basic graph patterns. For example, the query below has a different structure but would yield the same solutions as the previous query:

     PREFIX foaf:    <http://xmlns.com/foaf/0.1/> \\
     SELECT ?name ?mbox \\
     WHERE  { 
       { ?x foaf:name ?name . } 
       { ?x foaf:mbox ?mbox . } 
            } 

Value Constraints

Constraints can be given in an optional graph pattern. For example:

    {
    @prefix dc:   <http://purl.org/dc/elements/1.1/> . 
    @prefix :     <http://example.org/book/>   
    @prefix ns:   <http://example.org/ns#> .
    }
    :book1  dc:title  "SPARQL Tutorial" .
    :book1  ns:price  42 .
    :book2  dc:title  "The Semantic Web" .
    :book2  ns:price  23 .

Query:

    PREFIX  dc:  <http://purl.org/dc/elements/1.1/>
    PREFIX  ns:  <http://example.org/ns#>
    SELECT  ?title ?price
    WHERE   { ?x dc:title ?title .
    OPTIONAL { ?x ns:price ?price . FILTER (?price < 30) }
    }

Query results:

titleprice
„SPARQL Tutorial”
„The Semantic Web”23

Optional graph patterns

    {
    @prefix dc:   <http://purl.org/dc/elements/1.1/> . 
    @prefix :     <http://example.org/book/>   
    @prefix ns:   <http://example.org/ns#> .
    }
    :book1  dc:title  "SPARQL Tutorial" .
    :book1  ns:price  42 .
    :book2  dc:title  "The Semantic Web" .
    :book2  ns:price  23 .

Query:

    PREFIX  dc:  <http://purl.org/dc/elements/1.1/>
    PREFIX  ns:  <http://example.org/ns#>
    SELECT  ?title ?price
    WHERE   { ?x dc:title ?title .
    OPTIONAL { ?x ns:price ?price . FILTER (?price < 30) }
    }

Query results:

titleprice
„SPARQL Tutorial”
„The Semantic Web”23

Multiple Optional Blocks

Graph patterns are defined recursively. A graph pattern may have zero or more optional graph patterns, and any part of a query pattern may have an optional part. In this example, there are two optional graph patterns. Data:

    @prefix foaf:       <http://xmlns.com/foaf/0.1/> .
    
    _:a  foaf:name       "Alice" .
    _:a  foaf:homepage   <http://work.example.org/alice/> .
    
    _:b  foaf:name       "Bob" .
    _:b  foaf:mbox       <mailto:bob@work.example> .

Query:

    PREFIX foaf: <http://xmlns.com/foaf/0.1/>
    SELECT ?name ?mbox ?hpage
    WHERE  { ?x foaf:name  ?name .
             OPTIONAL { ?x foaf:mbox ?mbox } .
             OPTIONAL { ?x foaf:homepage ?hpage }
           }

Query result:

namemboxhpage
„Alice” <http://work.example.org/alice/>
„Bob”<mailto:bob@work.example>

Alternative Graph Patterns

Sprawozdanie

Prezentacja

Materiały

pl/miw/miw2009_llvm.1263223160.txt.gz · ostatnio zmienione: 2019/06/27 15:59 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0