SPARQL Query Forms


Published on

Examines the different SPARQL query forms to tease out their uses and applications

Published in: Technology, Education
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • SPARQL Query Forms

    1. 1. SPARQL Query Forms Leigh Dodds, Oxford SWIG, March 2008 Photo Credit: Glen Bowman
    2. 2. Why are there 4 SPARQL Query Forms? SPARQL Use Cases doesn’t help very much…
    3. 3. …neither does the SPARQL specification <ul><li>SELECT </li></ul><ul><li>Returns all, or a subset of, the variables bound in a query pattern match. </li></ul><ul><li>CONSTRUCT </li></ul><ul><li>Returns an RDF graph constructed by substituting variables in a set of triple templates. </li></ul><ul><li>ASK </li></ul><ul><li>Returns a boolean indicating whether a query pattern matches or not. </li></ul><ul><li>DESCRIBE </li></ul><ul><li>Returns an RDF graph that describes the resources found. </li></ul>
    4. 4. What are they for?
    5. 5. SELECT Equivalent to SQL SELECT Returns a nice, regular table
    6. 6. SELECT PREFIX table: <> SELECT ?name ?weight WHERE { ?element table:name ?name; table:atomicWeight ?weight. } ORDER BY DESC(?weight) LIMIT 10
    7. 7. ASK Returns a true/false value Is there data that looks like this ? Do you have any information about that ?
    8. 8. ASK PREFIX foaf: <> ASK WHERE { ?person a foaf:Person ; foaf:mbox <>. } (SPARQL equivalent of a vanity search!)
    9. 9. CONSTRUCT Returns an RDF graph Extract a specific subset of the queried data I want this , this , and this
    10. 10. CONSTRUCT PREFIX foaf: <> CONSTRUCT { ?friend a foaf:Person; foaf:name ?name; foaf:homepage ?home. } WHERE { ?person foaf:mbox <>; foaf:knows ?friend. ?friend foaf:name ?name; foaf:homepage ?home. }
    11. 11. DESCRIBE Returns an RDF graph Tell me about this or things that look like this … but you decide what’s relevant
    12. 12. DESCRIBE PREFIX foaf: <> DESCRIBE ?friend WHERE { ?person foaf:mbox “”; foaf:knows ?friend. }
    13. 13. Applied Uses Beyond the basics
    14. 14. DESCRIBE for Prototyping DESCRIBE <> Quickly assembling UIs Web APIs
    15. 15. SELECT for Indexing Building an ordering over some data ORDER BY, LIMIT
    16. 16. CONSTRUCT for Transformation … and also simple inferencing CONSTRUCT could be the XSLT of RDF Currently limited by lack of expressions in CONSTRUCT triple templates
    17. 17. CONSTRUCT for Transformation PREFIX foaf: <> PREFIX ex: <> CONSTRUCT { ?person a ex:Blogger. } WHERE { ?person foaf:weblog ?blog. }
    18. 18. SPARQL for Validation XSLT can be used for XML Validation (Schematron) SPARQL can be used for RDF Validation
    19. 19. Validation – ASK * ASK WHERE { #triple patterns that you don’t want to find } *Source: Talis Platform Field Predicate Map Validation
    20. 20. Validation – CONSTRUCT * CONSTRUCT { #some error message or data } WHERE { #triple patterns that you don’t want to find } *Source: Alistair Miles, Schemarama 2 Jena 2 Validation Support
    21. 21. In Combination?
    22. 22. The ADC Pattern ASK – DESCRIBE – CONSTRUCT Probe endpoint Grab default view of data Refine data extraction and/or apply transformation
    23. 23. Questions?
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.