Search code examples
sparqlsemantic-webdbpedialinked-data

Strings in Sparql


I'm playing around with DBPedia.

With this query I get all people who were born in London:

SELECT ?person
WHERE {      
  ?person dbo:birthPlace :London
}

But why I get an empty result when I execute this query?

SELECT ?person
WHERE {      
  ?person dbo:birthPlace "London"
}

I just changed London to a String.


Solution

  • This is because the object of this relation is an entity, and not a string, hence the absence of result with the second query.

    To know if a property (i.e dbo:birthPlace) relates an entity to a literal or not, one approach is to have a look at the "About" page of the property, for example, birthPlace's one.

    What can be seen there is that the type of birthPlace is owl:ObjectProperty, meaning that the object of the relation will have to be an entity, defined with a URI. The other possibility would be DatatypeProperty, as for the "abstract" property for example, where the object of the relation will be a literal.

    The fact that the birth place is an entity allows a lot of things, such as retrieving specific information about that place in the same query, for example.

    Hope that helps !