Can I combine local and remote dataset within SPAR

2020-07-11 06:30发布

问题:

I've been reading about SPARQL and RDF and please correct me if my reasoning about these technologies is wrong here.

Assuming that we have a local SPARQL database called LOCAL.. and url to remote RDF file called URL_RDF. Can I write a script lets say in PHP which will do a SPARQL query like this ?

Pseudo code.

SELECT * FROM LOCAL,URL_RDF WHERE LOCAL.id=URL_RDF.id

In other words can I combine sources within SPARQL query like this (remote file + local db) ?

回答1:

You can do this using the federation features in SPARQL 1.1. These are described at http://www.w3.org/TR/sparql11-federated-query, but to give you a quick impression of what it looks like, your example query would be something like this (still in pseudocode):

SELECT * WHERE {
  # the local part of the query
  ?s ?p ?id

  SERVICE <http://url/to/remote/data> {
    # The remote part of the query
    ?x ?y ?id
  }
}

Note that the URL would have to point to a SPARQL endpoint, i.e. a server that can respond to SPARQL queries, and not just a remote RDF file.