I’m trying to make a request which uses both bibleontology and dbpedia semantic databases:
PREFIX bibleontology: <http://bibleontology.com/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?art ?abstract WHERE {
bibleontology:Ezra owl:sameAs ?art .
?art dbo:abstract ?abstract .
}
This kind of request works on neither the bibleontology SPARQL endpoint, nor on the dbpedia SPARQL endpoint. Individual parts of the requests work fine on the each SPARQL endpoints.
Is it possible to join databases this way?
That query doesn’t work on neither dbpedia or bibleontology because the information is stored in two different databases and when you run a SPARQL query you basically hit one or the other. This means that you have to you download the data from both databases to put them in a local triple store in order to able to run a SPARQL query like the one you showed. Another option is to use a library that does that for you.
The Semantic Web Client Library will follow all URIs that you have in your SPARQL query and download the RDF data from each resource so that it can join all the triple patterns that appear in you query and give the answers.
You could run your query with some minor changes :
Explanation of the changes:
owlanddbpedianamespaces?art dbpedia:abstract ?abstract .you need to match thedbpedia:abstractpredicate to get the abstract instead ofbibleontology:abstractin order to get the abstract fromdbpediafilterto only retrieve abstracts in English, this is of course optional.Once you download “The Semantic Web Library” and you put your query in a file (i.e: query.sparql) you can run the following command to test your query:
All the command params are explained in the Semantic Web Client Library documentation.
You would get the following output:
I have omitted the long abstract from dbpedia for simplicity. The list of “Successfully dereferenced URIs” are documents retrieved by the library in order to answer your query. In the documentation of the library you’ll see how to run queries programatically in Java.