I am currently trying to learn how to query RDF data with SPARQL using resources on DBPedia and experimenting with the Virtuoso SPARQL Query Editor , but I seem to have misunderstood something.
For example, I am trying to find out the director name of Pulp Fiction, using this resource :
http://dbpedia.org/resource/Pulp_Fiction, so my (simple) query is:
SELECT ?dirName
FROM <http://dbpedia.org/resource/Pulp_Fiction>
WHERE
{
?s <http://dbpedia.org/property/director> ?dirName.
}
It works but the result is a URI resource : http://dbpedia.org/resource/Quentin_Tarantino.
Now i want to retrieve the birth name of the director, so i tried
SELECT ?dirRes ?dirName
FROM <http://dbpedia.org/resource/Pulp_Fiction>
WHERE
{
?s <http://dbpedia.org/property/director> ?dirRes.
?dirRes <http://dbpedia.org/ontology/birthDate> ?dirName.
}
without success, the result is an empty array…
Can someone help me with this ?
Thank you !
The
FROMpart selects the database that you want to query, not the entity.Remember that RDF consists of triples that have subject-predicate-object structure. You’re looking for:
So let’s query for that:
Now to get properties of the
?directorresource, add more triples to the query:You can make the query shorter by using predefined prefixes instead of the full
<...>URIs. You can get a list by clicking “Namespace prefixes” in the top right corner. If you have the choice between usingdbppropanddbpedia-owl, always go with the latter because the classes and properties in that namespace are better managed. Result: