2

I am using the following query to get Athletes data from DBpedia

  SELECT * WHERE {

  ?player a <http://dbpedia.org/ontology/Athlete> .
  ?player foaf:name ?firstname .
  ?player foaf:surname ?lastname .
  ?player <http://dbpedia.org/ontology/country> ?birthplace .
  ?player <http://dbpedia.org/ontology/birthDate> ?birthDate .
  ?player <http://dbpedia.org/ontology/Person/height> ?height .
  ?player <http://dbpedia.org/ontology/Person/weight> ?weight .
}

but I only get about 300 records!!

Can anyone tell me what is the problem here?

3

I had to make the last four attributes optional

  SELECT * WHERE {

  ?player a <http://dbpedia.org/ontology/Athlete> .
  ?player foaf:name ?firstname .
  ?player foaf:surname ?lastname .
  optional {?player <http://dbpedia.org/ontology/country> ?birthplace .}
  optional {?player <http://dbpedia.org/ontology/birthDate> ?birthDate .}
  optional {?player <http://dbpedia.org/ontology/Person/height> ?height .}
  optional {?player <http://dbpedia.org/ontology/Person/weight> ?weight .}
}

this way I could get all the records even when there are missing values

  • 1
    Note that you're not getting all the records straight off -- there are more than 650K solutions to this query, and you (currently) get 10K from the query as written. You can add a few clauses -- ORDER BY, LIMIT, OFFSET -- to step through the full solution set. Also note, you'll often get multiple rows for a single ?player -- because WIkipedia, and hence DBpedia, is full of dirty data. This may or may not matter to your use, but it's important to know. – TallTed Aug 18 '16 at 22:26
  • How can I prevent retrieving multiple rows for the same player? – Abdulrahman Bres Aug 19 '16 at 13:44
  • 1
    This depends on which attributes matter to you, and whether you care that there are other values for them. If you just add ORDER BY ?player to your query, you can see some of the dirtiness present. If you don't care about which value you get, SAMPLE is a useful tool. The query becomes too long for a comment, and I think this is a distinct question (which may have an answer already), so I won't go deeper here. – TallTed Aug 19 '16 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.