Search code examples
sparqldbpedia

Query DBPedia on "is [property] of"


I want to obtain a list of "is [property] of" items.

For example, Barack Obama on DBPedia has both "successor" as property and "is successor of" properties (with different successors!).

The first I can get with the following SPARQL query:

PREFIX ont: <http://dbpedia.org/ontology/>
PREFIX obama: <http://dbpedia.org/resource/Barack_Obama>
SELECT ?successor
WHERE{  
    obama: ont:successor ?successor
}  

How, can I get the list of items that satisfy "is successor of" criteria?


Solution

  • If you look closely, most of the is [property] of are defined as a has [property]. For example, the is successor of is defined as predecessor. Thus in your case you need to change your query to:

    PREFIX obama: <http://dbpedia.org/resource/Barack_Obama>
    SELECT *
    WHERE{  
        obama: dbpprop:predecessor ?successor
    }
    

    Just explore the main properties of DBpedia and such things pop out. Or as Jashua mentioned change the direction of the query:

    PREFIX obama: <http://dbpedia.org/resource/Barack_Obama>
    SELECT *
    WHERE{  
          ?successor dbpprop:successor obama:
    }