Re: Compiling information from several different triplestores

On Tue, May 5, 2009 at 5:33 AM, Nicolas Raoul
<nicolas.raoul.lists@gmail.com> wrote:
> Hello all,
>
> How can I run a query over several different triplestores ?
>
> For instance, I want to get a list of Anthony's friends.
> Triplestore1 says Jack is Tony's friend.
> Triplestore2 says Tony sameAs Anthony.
> What clever mechanism would undestand that Jack is Anthony's friend?
> Do I have to copy all information from both triplestores my own
> triplestore, or is there something smarter to do ?

Mos triplestores will let you use graph URIs that contain CONSTRUCT
queries on a SPARQL endpoint. This will transfer more information than
you need, but will often work if the data is not too large. The other
issue is that the resulting URL is unwieldy:

For instance:

PREFIX : <http://example.com/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

SELECT ?friend
FROM <triplestore1.uri>
where {
  ?person :hasFriend ?friend
  UNION {
    ?person :hasFriend ?f2
    GRAPH <http://triplestore2/sparql/?query=PREFIX+owl%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23%3E%0A%0ACONSTRUCT+%7B%3Fx+owl%3AsameAs+%3Fy%7D+WHERE+%7B%3Fx+owl%3AsameAs+%3Fy%7D>
{
      ?f2 owl:sameAs ?friend
    }
  }
}

The above query will find local friend statements (?person :hasFriend
?friend) and then import the owl:sameAs statements from the foreign
store to see their alternative URIs. Of course, I made up the URIs for
the 2 triplestores, but I'm sure you can adjust as necessary.

I don't know if all triplestores support this, but I believe Jena and
Sesame do, and I know that Mulgara does.

Regards,
Paul Gearon

Received on Tuesday, 5 May 2009 12:39:49 UTC