Search code examples
sparqldbpedia

Get birthplace and date of American investors from DBpedia people in SPARQL


I'm trying to get a list of Investors from the US, their birth dates, and places. But the SPARQL code below doesn't seem to work. I tried it on both

DBpedia pages: https://live.dbpedia.org/sparql or https://dbpedia.org/snorql/

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>

SELECT ?name ?birthPlace ?birthDate
WHERE {
  ?person a dbo:BusinessPerson, dbo:Entrepreneur, dbo:Investor .
  ?person dbo:birthPlace ?birthPlace .
  ?person dbo:birthDate ?birthDate .
  ?person dbo:country dbr:United_States .
  ?person rdfs:label ?name .
  FILTER(LANG(?name) = 'en')
}

Can't find any good literature on this subject either so having trouble understanding what I should alter.

All advice is appreciated.


Solution

  • Try the following query here:

    SELECT distinct ?person ?label ?birthPlace ?birthDate 
    WHERE {
     {
       ?person rdf:type dbo:Person.
       ?person ?p dbr:Investor.
       ?person dbo:nationality dbr:United_States.
       ?person rdfs:label ?label. FILTER (lang(?label) = 'en')
       OPTIONAL{?person dbp:birthPlace ?birthPlace.} 
       OPTIONAL{?person dbo:birthDate ?birthDate }
     }
    Union
     {
       ?person rdf:type dbo:Person.
       ?person ?p dbo:Entrepreneur.
       ?person dbo:nationality dbr:United_States.
       ?person rdfs:label ?label. FILTER (lang(?label) = 'en')
       OPTIONAL{?person dbp:birthPlace ?birthPlace.} 
       OPTIONAL{?person dbo:birthDate ?birthDate }
     }
    Union
     {
       ?person rdf:type dbo:Person.
       ?person a dbo:BusinessPerson.
       ?person dbo:nationality dbr:United_States.
       ?person rdfs:label ?label. FILTER (lang(?label) = 'en')
       OPTIONAL{?person dbp:birthPlace ?birthPlace.} 
       OPTIONAL{?person dbo:birthDate ?birthDate }
     }
    }
    

    you can also try this equivalent query on wikidata SPARQL endpoint here:

    SELECT ?person ?personLabel ?dob ?pobLabel
    WHERE 
    {
      ?person wdt:P31 wd:Q5.
      ?person wdt:P106 wd:Q557880. 
      ?person wdt:P27 wd:Q30. 
      OPTIONAL {?person wdt:P569 ?dob.}
      OPTIONAL {?person wdt:P19 ?pob. }
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 
    }