Mapping based properties are using the namespace http://dbpedia.org/ontology/
, thus, the prefix must be dbo
instead of dbp
, which stands for http://dbpedia.org/property/
.
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT ?book ?genre ?date ?numberOfPages
WHERE {
?book a dbo:Book ;
dbp:genre ?genre ;
dbo:firstPublicationDate ?date .
OPTIONAL {?book dbp:numberOfPages ?numberOfPages .}
}
Some additional comments:
- put the prefixes to the SPARQL query such that others here can run it without any exceptions (also in the future) - the current SPARQL query uses
dbpedia-owl
but this one is not pre-defined on the official DBpedia anymore - it's called dbo
instead
- which brings me to the second point -> if you're using a public SPARQL endpoint, show its URL
you can start debugging your own SPARQL query by simply starting with only parts of it and adding more triple patterns then, e.g. in your case you could check if there is any triple with the property with
PREFIX dbp: <http://dbpedia.org/property/>
SELECT * WHERE {?book dbp:firstPublicationDate ?date } LIMIT 10
Update
As Ivo Velitchkov noticed in his answer below, the property dbo:firstPublicationDate
is only used for mangas, etc., i.e. written work that was published periodically. Thus, the result will be empty.