- From: Seaborne, Andy <andy.seaborne@hp.com>
- Date: Tue, 5 May 2009 13:46:53 +0000
- To: Paul Gearon <gearon@ieee.org>, Nicolas Raoul <nicolas.raoul.lists@gmail.com>
- CC: "semantic-web@w3.org" <semantic-web@w3.org>
> -----Original Message----- > From: semantic-web-request@w3.org [mailto:semantic-web-request@w3.org] > On Behalf Of Paul Gearon > Sent: 5 May 2009 13:39 > To: Nicolas Raoul > Cc: semantic-web@w3.org > Subject: 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. Jena/ARQ provides a SERVICE extension for dynamic callout to other SPARQL endpoints. http://jena.sourceforge.net/ARQ/service.html I played with dynamic graph fetching (so not a SPARQL endpoint): http://seaborne.blogspot.com/2008/10/walking-web.html You an use a URL in FROM: PREFIX : <http://example.com/> PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT ?friend FROM <triplestore1.uri> FROM <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> where { ?person :hasFriend ?friend UNION { ?person :hasFriend ?f2 ?f2 owl:sameAs ?friend } } } Andy > > Regards, > Paul Gearon
Received on Tuesday, 5 May 2009 13:48:13 UTC