SPARQL Query Examples
Find all albums a group created, LEVEL1
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?album
WHERE
{
?album a mo:Album;
dc:creator <http://mm.musicbrainz.org/artist/65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab>.
}
ORDER BY ?album
Find all musical manifestations a group produced, after 1981, LEVEL1
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX dc: <http://purl.org/dc/terms/>
SELECT ?title
WHERE
{
?album a mo:MusicalManifestation;
dc:creator <http://mm.musicbrainz.org/artist/65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab>;
dc:created ?creation_date.
OPTIONAL{?album dc:title ?title}.
FILTER ( xsd:dateTime(?creation_date) > "1981-01-01 00:00:00"^^xsd:dateTime ) .
}
Find all albums containing a particular track, LEVEL1
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX mu: <http://purl.org/NET/c4dm/music.owl#>
SELECT ?release
WHERE
{
?sound mo:hasMusicalManifestation <http://mm.musicbrainz.org/track/5fb524f1-8cc8-4c04-a921-e34c0a911ea7>.
?release rdf:type mo:MusicalManifestation;
mo:has_track ?t.
?sound mo:hasMusicalManifestation ?t.
}
Find musical instruments pertaining to the creation of a particular track, LEVEL2
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX mu: <http://purl.org/NET/c4dm/music.owl#>
PREFIC event: <http://purl.org/NET/c4dm/event.owl#>
SELECT ?instrument
WHERE
{
?sound mo:hasMusicalManifestation <http://mm.musicbrainz.org/track/5fb524f1-8cc8-4c04-a921-e34c0a911ea7>.
?performance event:hasProduct ?sound.
{
?performance event:hasFactor ?instrument.
?instrument a mu:Instrument.
}
UNION
{
?performance event:hasSubEvent ?subperformance.
?subperformance event:hasFactor ?instrument.
?instrument a mu:Instrument.
}
}
Find me tracks containing a section of at least 2 minutes and 10 seconds which is in E minor, LEVEL3:
(we might want to express this duration on a more "musically relevant" time line)
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX mu: <http://purl.org/NET/c4dm/music.owl#>
PREFIC event: <http://purl.org/NET/c4dm/event.owl#>
PREFIX time: <http://www.w3.org/2006/time#>
PREFIX timeline: <http://purl.org/NET/c4dm/time.owl#>
PREFIX keys: <http://purl.org/NET/c4dm/keys.owl#>
SELECT ?track
WHERE
{
?track a mo:Track.
?snd mo:hasMusicalManifestation ?track.
?perf a mu:Performance;
event:hasProduct ?snd.
?perf event:hasSubEvent ?subperf.
?subperf event:time ?time;
event:hasFactor keys:EMinor.
?time a time:TimeInterval;
timeline:onTimeLine ?timeline;
timeline:durationXSD ?duration.
?timeline a timeline:AbstractTimeLine.
FILTER (xsd:duration(?duration) >= "PT2M10S"^^xsd:duration).
}
--
YvesRaimond - 13 Feb 2007
Topic revision: r4 - 2007-02-14 - 16:43:52 -
YvesRaimond