W3C home > Mailing lists > Public > public-lod@w3.org > August 2008

Re: soliciting your favorite (public) SPARQL queries!

From: Yves Raimond <yves.raimond@gmail.com>
Date: Thu, 21 Aug 2008 08:26:52 +0100
Message-ID: <82593ac00808210026n1cb2c383qe0d8486664ec63a8@mail.gmail.com>
To: "Lee Feigenbaum" <lee@thefigtrees.net>
Cc: public-sparql-dev@w3.org, public-lod@w3.org

Hello!

>
> I'm putting together a "SPARQL by Example" tutorial, which is, as the name
> suggests, a step-by-step introduction to SPARQL taught almost entirely
> through complete, runnable SPARQL queries.
>
> So far, I've gathered a great deal of example queries myself, but I know
> that many subscribers to these lists probably have favorite queries of their
> own that you might be willing to share with me.
>
> I'm looking for:
>
> 1) SPARQL queries
> 2) ...that can be run by anyone (no private data sets)
> 3a)...either by running the query against a public SPARQL endpoint
> 3b)...or by using a public SPARQL endpoint that will fetch HTTP-accessible
> RDF data (e.g. sparql.org or demo.openlinksw.com)
> 4) ...that answers a real* question
> 5) ...and that is fun!**
>
> * real is in the eye of the beholder, I imagine, but I'm not looking for
>  "finds the predicates that relate ex:s and ex:o in this sample RDF graph"
>
> ** fun is also in the eye of the beholder. fun can be a query on fun data; a
> clever query that may illustrate a particular SPARQL construct ("trick"); a
> query that integrates interesting information; a query with surprising
> results; etc.

I quite like this one:

PREFIX geo: <http://www.geonames.org/ontology#>
PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT DISTINCT ?an ?lat ?long ?name ?population
WHERE
{ ?a
     a mo:MusicArtist;
     foaf:based_near ?place;
     foaf:name ?an;
     foaf:made ?alb.
  ?alb tags:taggedWithTag <http://dbtune.org/jamendo/tag/punk>.
  ?place
     geo:name ?name;
     geo:population ?population;
     wgs:lat ?lat;
     wgs:long ?long }
ORDER BY ?population

on http://dbtune.org/jamendo/ (order me bands that have been tagged as
`punk' by a Jamendo user by the number of inhabitants in their city)

Or that one:

SELECT ?brand ?title ?count
WHERE {
   ?artist a mo:MusicArtist;
      foaf:name "The Beatles".
   ?pc pc:object ?artist;
       pc:count ?count.
   ?brand a po:Brand;
       pc:playcount ?pc;
       dc:title ?title
    FILTER (?count>10)}

on http://dbtune.org/bbc/playcount/ (give me BBC shows on which the
Beatles have been featured more than 10 times)

Or that one:

PREFIX af: <http://purl.org/ontology/af/>
PREFIX event: <http://purl.org/NET/c4dm/event.owl#>
PREFIX tl: <http://purl.org/NET/c4dm/timeline.owl#>

SELECT ?start ?duration
FROM <http://dbtune.org/echonest/analyze-example.rdf>
WHERE
{
?e      a af:StructuralSegment;
        event:time ?time.
?time   tl:start ?start;
        tl:duration ?duration.
}

Using the GRDDL'ed results of the Echonest Analyse API, and getting
structural segments (eg. chorus, verse, etc.) on a particular track.

And finally, this one:

PREFIX void: <http://purl.org/ontology/void#>
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX tags: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/>

ASK
FROM NAMED <http://moustaki.org/void/void.n3>
FROM NAMED <http://moustaki.org/void/jamendo_example.n3>
{
        GRAPH <http://moustaki.org/void/void.n3> {
                ?ds a void:Dataset;
                        void:sparql_end_point ?sparql;
                        void:example ?ex.
        }
        GRAPH ?ex {
                ?r a mo:Record;
                        mo:available_as ?l;
                        tags:taggedWithTag ?t.
        }
}

Which is explained in more details at
http://blog.dbtune.org/post/2008/06/12/Describing-the-content-of-RDF-datasets

Cheers!
y
Received on Thursday, 21 August 2008 07:27:29 UTC

This archive was generated by hypermail 2.3.1 : Sunday, 31 March 2013 14:24:17 UTC