SPARQL Query Forms
Upcoming SlideShare
Loading in...5
×
 

SPARQL Query Forms

on

  • 8,448 views

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

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

Statistics

Views

Total Views
8,448
Views on SlideShare
8,358
Embed Views
90

Actions

Likes
2
Downloads
123
Comments
0

4 Embeds 90

http://www.ldodds.com 62
http://www.slideshare.net 23
http://planetrdf.com 4
http://www.semanticaweb.info 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

SPARQL Query Forms SPARQL Query Forms Presentation Transcript

  • SPARQL Query Forms Leigh Dodds, Oxford SWIG, March 2008 Photo Credit: Glen Bowman
  • Why are there 4 SPARQL Query Forms? SPARQL Use Cases doesn’t help very much…
  • …neither does the SPARQL specification
    • SELECT
    • Returns all, or a subset of, the variables bound in a query pattern match.
    • CONSTRUCT
    • Returns an RDF graph constructed by substituting variables in a set of triple templates.
    • ASK
    • Returns a boolean indicating whether a query pattern matches or not.
    • DESCRIBE
    • Returns an RDF graph that describes the resources found.
  • What are they for?
  • SELECT Equivalent to SQL SELECT Returns a nice, regular table
  • SELECT PREFIX table: <http://www.daml.org/2003/01/periodictable/PeriodicTable#> SELECT ?name ?weight WHERE { ?element table:name ?name; table:atomicWeight ?weight. } ORDER BY DESC(?weight) LIMIT 10
  • ASK Returns a true/false value Is there data that looks like this ? Do you have any information about that ?
  • ASK PREFIX foaf: <http://xmlns.com/foaf/0.1/> ASK WHERE { ?person a foaf:Person ; foaf:mbox <mailto:leigh@ldodds.com>. } (SPARQL equivalent of a vanity search!)
  • CONSTRUCT Returns an RDF graph Extract a specific subset of the queried data I want this , this , and this
  • CONSTRUCT PREFIX foaf: <http://xmlns.com/foaf/0.1/> CONSTRUCT { ?friend a foaf:Person; foaf:name ?name; foaf:homepage ?home. } WHERE { ?person foaf:mbox <mailto:leigh@ldodds.com>; foaf:knows ?friend. ?friend foaf:name ?name; foaf:homepage ?home. }
  • DESCRIBE Returns an RDF graph Tell me about this or things that look like this … but you decide what’s relevant
  • DESCRIBE PREFIX foaf: <http://xmlns.com/foaf/0.1/> DESCRIBE ?friend WHERE { ?person foaf:mbox “mailto:leigh@ldodds.com”; foaf:knows ?friend. }
  • Applied Uses Beyond the basics
  • DESCRIBE for Prototyping DESCRIBE <http://example.org/someResource> Quickly assembling UIs Web APIs
  • SELECT for Indexing Building an ordering over some data ORDER BY, LIMIT
  • CONSTRUCT for Transformation … and also simple inferencing CONSTRUCT could be the XSLT of RDF Currently limited by lack of expressions in CONSTRUCT triple templates
  • CONSTRUCT for Transformation PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX ex: <http://www.example.org/blogger/> CONSTRUCT { ?person a ex:Blogger. } WHERE { ?person foaf:weblog ?blog. }
  • SPARQL for Validation XSLT can be used for XML Validation (Schematron) SPARQL can be used for RDF Validation
  • Validation – ASK * ASK WHERE { #triple patterns that you don’t want to find } *Source: Talis Platform Field Predicate Map Validation
  • 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
  • In Combination?
  • The ADC Pattern ASK – DESCRIBE – CONSTRUCT Probe endpoint Grab default view of data Refine data extraction and/or apply transformation
  • Questions?