Web Search
Recent Changes - Search:

SampleSPARQLQueries

Sources of sample queries to help familiarize you with SPARQL

First, try Leigh Dodds' blog page

Also, Bob DuCharme has done an excellent job of curating public collections of RDF on his site rdfdata.org(approve sites)

Kingsley Idehen has a collection of sample queries(approve sites).

w3c sparql test cases(approve sites)

Here are some of my own:

States in Austria

 SELECT * WHERE {
   ?c state ?state .
   ?c country Austria .
 }

Titles, Authors,

This...

 PREFIX dc: <http://purl.org/dc/elements/1.1/>(approve sites)
 SELECT ?book ?title ?authorname
 WHERE {
 ?book dc:creator ?author .
 ?author dc:type <http ://hoppa.com/Painters/> .
      ?author dc:title ?authorname .
      ?book dc:title ?title .
 }

is from http://danbri.org/words/2005/07/04/103(approve sites) try it here(approve sites)

Buildings with defined # of floors:

snorql query

 SELECT *
 WHERE { 
  ?building dbpedia2:building_name ?name .
  ?building dbpedia2:height_stories ?stories .
 }

This produces a surprisingly short list.

This...

 SELECT *
 WHERE { 
   ?building dbpedia2:building_name ?name .
   ?building dbpedia2:height_stories ?stories .
 }

Shows all the named buildings. Or this shows all buildings in NYC, and shows where the missing # floors are. This could be used to QA and update the data in Wikipedia to improve it (as well as dbpedia). snorql query

 SELECT *
 WHERE { 
   ?building dbpedia2:building_name ?name .
   ?building dbpedia2:location ?location .
   OPTIONAL { ?building dbpedia2:height_stories ?stories }

   FILTER regex(?location, "York", "i")

}


Language-specific queries

How to get sparql queries to return results in a specific language

 FILTER (lang(?hasValue) = "" || langMatches(lang(?hasValue), "EN"))

sparql operators

Comment (function:DisplayCommentsCount ) Edit - History - Print - Recent Changes - Search
Page last modified on April 26, 2007, at 01:38 PM