OWL ontologies (what we're working with) aren't object oriented programming languages. Properties don't belong to classes. When we say that the domain of a property P is a class D, it means that when we see a triple on the property, e.g., X P Y, we can infer that X is a D. That's all it means. When the mapping page for University says that locationCity is a property on University, I think that what it means is that the domain of locationCity is a superclass of University, so it wouldn't be inconsistent if a University has a locationCity. I'm basing this on the results of the simple describe query describe dbpedia-owl:locationCity
, which has these results (note that the domain of locationCity is Organisation, and that Organisation is a superclass of University):
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dbpedia-owl: <http://dbpedia.org/ontology/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
dbpedia-owl:locationCity
rdf:type owl:ObjectProperty ;
rdfs:domain dbpedia-owl:Organisation ;
rdfs:range dbpedia-owl:City ;
rdfs:label "locatie stad"@nl , "ville"@fr , "location city"@en ;
rdfs:comment "City the thing is located."@en .
In general, it's useful to see what's actually in the data, and base your queries on that.For instance, you might look at the data that is defined for Rensselaer Polytechnic Institute and notice, for instance, that for the property
dbpedia-owl:city
it has the value dbpedia:Troy,_New_York
. If you want to select things that have type dbpedia-owl:University
(i.e., have dbpedia-owl:University
as a value of the rdf:type
property) and their values for the dbpedia-owl:city
property, you just ask for it:
select ?university ?city where {
?university rdf:type dbpedia-owl:University .
?university dbpedia-owl:city ?city .
}
SPARQL results
In SPARQL, you can use a
as an abbreviation for rdf:type
, and when you have multiple triples with the same subject, you can combine them with the ;
syntax, so we can make that query nicer looking as follows:
select ?university ?city where {
?university rdf:type dbpedia-owl:University ;
dbpedia-owl:city ?city .
}
SPARQL results
Notice that I'm using the dbpedia-owl:
properties here. These come from the DBpedia ontology, and that has much cleaner data than the raw infobox data (the dbpprop:
properties). I've discussed this a bit more in this answer to Why there is differences in the number of links connected to the same property?.
Basing your queries on the data is actually pretty important. While the mappings wiki, as you saw, mentioned the locationCity property, it's not actually used on any Universities in the data:
select ?university ?city where {
?university a dbpedia-owl:University ;
dbpedia-owl:locationCity ?city .
}
SPARQL results (no results)
You can even use SPARQL to find out what dbpedia-owl:
properties have been used to relate Universities to Cities:
select distinct ?p where {
?university a dbpedia-owl:University ;
?p [ a dbpedia-owl:City ] .
filter strstarts(str(?p),str(dbpedia-owl:))
}
SPARQL results
p
-------------------------------------------------
http://dbpedia.org/ontology/city
http://dbpedia.org/ontology/campus
http://dbpedia.org/ontology/state
http://dbpedia.org/ontology/affiliation
http://dbpedia.org/ontology/province
http://dbpedia.org/ontology/country
http://dbpedia.org/ontology/location
http://dbpedia.org/ontology/wikiPageRedirects
http://dbpedia.org/ontology/wikiPageDisambiguates
http://dbpedia.org/ontology/president
http://dbpedia.org/ontology/type
It's not immediately clear why some of those would be used (e.g., president, or type), but I can see where some might be used, if perhaps incorrectly (e.g., state, or province).