Sample LinkedMusic Queries - DDMAL/linkedmusic-datalake GitHub Wiki
SPARQL Protocol and RDF Query Language (SPARQL) is the standard RDF query language developed by W3C and allows users to retrieve and compile information from multiple RDF sources. SPARQL has been integrated into both Wikidata and Virtuoso, making it easily accessible for LinkedMusic's purposes.
Refer to the official documentation for more information.
As of 4 July 2025, these benchmark queries are recorded in a Google Sheet.
| Challenge | Definition |
|---|---|
| Challenge 1 | Find anything you can find via the database's website. |
| Challenge 2 | Find anything you can find beyond what you can find on the website because you have a full access to the database. |
| Challenge 3 | Find anything you can find with the database plus using the information in Wikidata, e.g., the gender of the musician. |
| Challenge 4 | Find anything across different databases and Wikidata. |
More sample queries in natural language can be found here.
| Database | Query | SPARQL |
| DIAMM | Find all compositions in DIAMM that are composed by Guillaume de Machaut |
SELECT ?composition
WHERE {
GRAPH diamm: {
?composer wdt:P2888 wd:Q200580 .
?composition wdt:P86 ?composer .
}
} |
| The Session | Find all sessions in France in The Session |
SELECT ?session
WHERE {
GRAPH ts: {
?session a ts:Session ;
wdt:P17 wd:Q142 .
}
} |
| MusicBrainz | Find all MusicBrainz recordings made by Taylor Swift |
SELECT ?recording
WHERE {
GRAPH mb:{
?artist a mb:Artist .
?artist wdt:P2888 wd:Q26876 .
?recording a mb:Recording .
?recording wdt:P175 ?artist .
}
} |
| The Global Jukebox | Find all Ethiopian songs in The Global Jukebox |
SELECT ?song ?songLabel
WHERE {
GRAPH <https://linkedmusic.ca/graphs/theglobaljukebox/> {
?song rdf:type gj:Song .
?song wdt:P495 wd:Q115 .
OPTIONAL { ?song rdfs:label ?songLabel . }
}
} |
| Dig That Lick (DTL1000) | Find all solos in Dig That Lick |
SELECT ?solo
WHERE {
GRAPH <https://linkedmusic.ca/graphs/dig-that-lick/> {
?solo rdf:type dtl:Solo
}
}
|
| Cantus DB | Find all chants in Cantus DB in lydian mode. |
SELECT ?chant
WHERE {
GRAPH cdb: {
?chant wdt:P826 wd:Q686115
}
}
|
| RISM | Find all sources in RISM held in the Bibliothèque nationale de France. |
SELECT ?source
WHERE {
GRAPH rism: {
?source wdt:P276 ?institution .
?institution wdt:P2888 wd:Q193563 .
}
} |
Find anything you can find beyond what you can find on the website because you have a full access to the database.
| Database | Query | SPARQL |
| DIAMM | Find all DIAMM archives and sort them by the number of sources that they contain |
SELECT ?archive (COUNT(?source) AS ?sourceCount)
WHERE {
?archive a diamm:Archive .
OPTIONAL {
?source a diamm:Source ;
wdt:P276 ?archive .
}
}
GROUP BY ?archive
ORDER BY DESC(?sourceCount) |
| The Session | Find all the different time signatures for jigs in The Session |
SELECT DISTINCT ?timeSignature
WHERE {
?tune a ts:Tune .
?tune wdt:P747 ?tuneSetting .
?tuneSetting wdt:P136 wd:Q1079270 .
?tuneSetting wdt:P3440 ?timeSignature .
}
ORDER BY ?timeSignature |
| MusicBrainz | Find all bands that share at least two members with Radiohead in MusicBrainz |
SELECT ?band (COUNT(DISTINCT ?sharedMember) AS ?sharedMemberCount)
WHERE {
?radiohead a mb:Artist ;
wdt:P2888 wd:Q44190 .
?radiohead wdt:P527 ?radiomember .
?band a mb:Artist ;
wdt:P527 ?radiomember ;
wdt:P527 ?sharedMember .
?radiohead wdt:P527 ?sharedMember .
FILTER(?band != ?radiohead)
} GROUP BY ?band ?bandLabel
HAVING (COUNT(DISTINCT ?sharedMember) >= 2)
ORDER BY DESC(?sharedMemberCount)
|
| The Global Jukebox | Find all Global Jukebox cultures that have at least one song with flute instrumentation |
SELECT DISTINCT ?culture
WHERE {
?song a gj:Song .
?song wdt:P2596 ?culture .
?song wdt:P870 wd:Q11405 .
?culture a gj:Culture .
} |
| Dig That Lick (DTL1000) | Find all tracks in Dig That Lick recorded in New York City |
SELECT DISTINCT ?track
WHERE {
GRAPH dtl: {
?track a dtl:Track .
?track wdt:P8546 wd:Q60 .
}
} |
| Cantus DB | N/A |
Cantus DB is developed and maintained by DDMAL; the search feature was intentionally designed to allow users full access to the dataset information. |
| RISM | Find compositions by Mendelssohn in RISM written in 9/8 time. |
SELECT ?source
WHERE {
GRAPH rism: {
?source wdt:P86 ?mendelssohn .
?mendelssohn wdt:P2888 wd:Q46096 .
?source wdt:P1922 ?incipit .
?incipit wdt:P3440 "9/8".
}
} |
Find anything you can find with the database plus using the information in Wikidata, e.g., the gender of the musician.
| Database | Query | SPARQL |
| DIAMM | Find archives in DIAMM with an inception after 1900 |
SELECT DISTINCT ?archive
WHERE {
GRAPH diamm: {
?archive a diamm:Archive ;
wdt:P2888 ?archiveWikidata .
}
SERVICE <https://query.wikidata.org/sparql> {
?archiveWikidata wdt:P571 ?inceptionDate .
FILTER (YEAR(?inceptionDate) > 1900)
} |
| The Session | Find the capital city of the country with the most sessions |
SELECT ?capitalCity ?capitalCityLabel
WHERE {
{
SELECT ?country (COUNT(?session) AS ?sessionCount)
WHERE {
GRAPH ts: {
?session a ts:Session .
?session wdt:P17 ?country .
}
}
GROUP BY ?country
ORDER BY DESC(?sessionCount)
LIMIT 1
}
SERVICE <https://query.wikidata.org/sparql> {
?country wdt:P36 ?capitalCity .
?capitalCity rdfs:label ?capitalCityLabel .
FILTER (LANG(?capitalCityLabel) = "en")
}
} |
| MusicBrainz | What’s the average number of record labels that female singers in MusicBrainz have signed with? |
SELECT (AVG(?labelCount) AS ?averageLabelsPerSinger)
WHERE {
{
SELECT ?artist (COUNT(DISTINCT ?label) AS ?labelCount)
WHERE {
GRAPH mb: {
?artist a mb:Artist .
?artist wdt:P2888 ?artistWikidata .
?artist wdt:P264 ?label .
?artist wdt:P21 wd:Q6581072 .
}
SERVICE <https://query.wikidata.org/sparql> {
?artistWikidata wdt:P106 wd:Q177220 .
}
}
GROUP BY ?artist
}
} |
| The Global Jukebox | Find all Global Jukebox songs from Africa |
SELECT DISTINCT ?song
WHERE {
GRAPH gj: {
?song a gj:Song .
?song wdt:P2596 ?culture .
?culture wdt:P17 ?country .
}
SERVICE <https://query.wikidata.org/sparql> {
?country wdt:P30 wd:Q15 . # QID for Africa
}
} |
| Dig That Lick (DTL1000) | Count how many solos were done by artists of each gender in Dig That Lick |
SELECT ?gender (COUNT(?solo) AS ?soloCount)
WHERE {
GRAPH dtl: {
?solo a dtl:Solo ;
wdt:P175 ?artist .
}
SERVICE <https://query.wikidata.org/sparql> {
?artist wdt:P21 ?gender . # P21 is "sex or gender"
}
}
GROUP BY ?gender |
| Cantus DB |
|
|
| RISM | Find composers in RISM who have siblings who are also composers in RISM. Note: this query needs workshopping. |
SELECT DISTINCT ?composer
WHERE {
GRAPH rism: {
?work wdt:P86 ?composer .
?composer wdt:P2888 ?wikicomposer .
}
SERVICE <https://query.wikidata.org/sparql> {
?wikisibling wdt:P3373 ?wikicomposer .
}
GRAPH rism: {
?sibling wdt:P2888 ?wikisibling .
?work2 wdt:P86 ?sibling .
}
} |
| Databases | Query | SPARQL |
| The Global Jukebox, The Session | Find all songs in The Global Jukebox from countries with more than four sessions in the Session |
SELECT DISTINCT ?song
WHERE {
GRAPH gj: {
?song a gj:Song ;
wdt:P495 ?country .
}
GRAPH ts: {
SELECT ?country (COUNT(DISTINCT ?session) AS ?sessionCount)
WHERE {
?session a ts:Session ;
wdt:P17 ?country .
}
GROUP BY ?country
HAVING (COUNT(DISTINCT ?session) > 4)
}
} |
| MusicBrainz, Dig That Lick | Find all works in MusicBrainz that, according to Dig that Lick, contains a solo performed by Charlie Parker |
SELECT DISTINCT ?work
WHERE {
GRAPH dtl: {
?solo a dtl:Solo ;
wdt:P175 wd:Q103767 ;
wdt:P361 ?track .
?track wdt:P2888 ?wikidataWork .
}
GRAPH mb: {
?work a mb:Work ;
wdt:P2888 ?wikidataWork .
}
} |
| MusicBrainz, Dig That Lick, The Session, DIAMM, The Global Jukebox | Find all compositions or recordings with "death" in the title |
SELECT DISTINCT ?entity ?label
WHERE {
{
GRAPH mb: {
?entity rdf:type mb:Work .
?entity rdfs:label ?label .
FILTER (CONTAINS(LCASE(STR(?label)), "death"))
}
}
UNION
{
GRAPH mb: {
?entity rdf:type mb:Recording .
?entity rdfs:label ?label .
FILTER (CONTAINS(LCASE(STR(?label)), "death"))
}
}
UNION
{
GRAPH diamm: {
?entity rdf:type diamm:Composition .
?entity rdfs:label ?label .
FILTER (CONTAINS(LCASE(STR(?label)), "death"))
}
}
UNION
{
GRAPH ts: {
?entity rdf:type ts:Recording .
?entity rdfs:label ?label .
FILTER (CONTAINS(LCASE(STR(?label)), "death"))
}
}
UNION
{
GRAPH dtl: {
?entity rdf:type dtl:Track .
?entity rdfs:label ?label .
FILTER (CONTAINS(LCASE(STR(?label)), "death"))
}
}
UNION
{
GRAPH ts: {
?entity rdf:type ts:Tune .
?entity rdfs:label ?label .
FILTER (CONTAINS(LCASE(STR(?label)), "death"))
}
}
UNION
{
GRAPH gj: {
?entity rdf:type gj:Song .
?entity rdfs:label ?label .
FILTER (CONTAINS(LCASE(STR(?label)), "death"))
}
}
} |
| MusicBrainz, The Global Jukebox | Find all musical instruments in the Global Jukebox featured in songs indigenous to Madagascar, and find recordings in MusicBrainz featuring these same instruments |
SELECT DISTINCT ?wikidataInstrument ?recording WHERE {
GRAPH gj: {
?song wdt:P495 wd:Q1019 .
?song wdt:P870 ?wikidataInstrument .
}
GRAPH mb: {
?recording wdt:P870 ?musicBrainzInstrument .
?musicBrainzInstrument wdt:P2888 ?wikidataInstrument .
}
} |
| MusicBrainz, The Session | Find all music events that happened on a day where at least one South Korean music label dissolved |
SELECT DISTINCT ?event WHERE {
GRAPH mb: {
?label a mb:Label ;
wdt:P17 ?area ;
wdt:P576 ?dissolutionDate .
?area wdt:P2888 wd:Q884 .
}
{
GRAPH ts: {
?event a ts:Events ;
wdt:P580 ?eventDate .
}
}
UNION
{
GRAPH mb: {
?event a mb:Event ;
wdt:P585 ?eventDate .
}
}
FILTER (?eventDate = ?dissolutionDate)
} |
This section contains a list of sample queries that could not be done without LinkedMusic. They either query across multiple databases or offer search functionality that does not currently exist in the original database. The formulation of these queries should require no technical experience or background.
| Query | Notes |
|---|---|
| Give me a list of Sessions that took place in Greece. | As of 16 June 2025, The Session does not support location-based queries. When you filter sessions with the keyword 'Greece,' sessions in the USA and Austria are returned as well. |
| Find all album cover arts for albums released in 1959 that were released by surf rock bands. | Cover Art Archive + MusicBrainz (and others) |
| Return all Proper chants composed in Southern France that are in mixolydian mode | The LLM may have to clarify the definition of 'Southern France' |
| Are there manuscripts on DIAMM and Cantus Database? | ... |
| What genres are on Cantus Database as well as DIAMM? | DIAMM considers a number of things genres that CDB doesn't, or is folded in specifically under another CDB genre, ex. propers |
| What items from [Seville/Spain] are affiliated with women? | (nunnery, scribe, matroness) |
| What items in DIAMM and Cantus DB are related in any way to [place]? | Will net origin, holding, transmission, selling, etc. |
| What items have external links on both databases? What items have IIIF manifests? | not all pages have both, etc |
| Find recordings of advent chants | Cantus DB and MusicBrainz |
| Find recordings of compositions by female composers | RISM and MusicBrainz |
| Find compositions that were published in one country and recorded in another | RISM and MusicBrainz |
| Find chants, the location of their source, and a recording | Cantus DB/Wikidata/MusicBrainz |
| Find RISM sources from eastern Asia | RISM and Wikidata |
| In RISM, find the number of sources from south of the equator | RISM and Wikidata |