Can I combine local and remote dataset within SPARQL query?

a 夏天 提交于 2019-12-06 02:01:00

问题


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.



来源:https://stackoverflow.com/questions/7918372/can-i-combine-local-and-remote-dataset-within-sparql-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!