Search code examples
sparqldbpedia

SPARQL: How to retrieve all dog breeds and all their infobox data from dbpedia?


I would like to know how is the best sparql way to retrieve all dog breeds and all their infobox data from dbpedia. I've tried this:

SELECT * WHERE {
{
  <http://dbpedia.org/resource/Dog_type> ?p ?o
}
UNION
{
  ?s ?p <http://dbpedia.org/resource/Dog_type> .
  ?s ?p ?o .
  ?p ?p2 ?o2  
}
}

But the result is far away from I expect like:

http://dbpedia.org/resource/Basque_Shepherd_Dog dbpedia2:coat "moderately long"^^rdf:langString

Solution

  • First, note that <http://dbpedia.org/resource/Dog_type> is not the class of dog breeds.

    For several reasons, I suggest you do this work on DBpedia Live, rather than DBpedia [Snapshot].

    Start there with a look at the description of your example breed, http://dbpedia.org/resource/Basque_Shepherd_Dog.

    Then consider whether a query like the following will get you what you want --

    SELECT DISTINCT * 
    WHERE
     { 
       ?breed a  <http://dbpedia.org/class/yago/DogBreeds> ;
              ?p ?o 
     }
    ORDER BY ?breed ?p ?o
    LIMIT 1000