[redland-dev] SPARQL, Redland and circular queries
Kieron Taylor
krt1 at soton.ac.uk
Mon Feb 13 15:06:23 GMT 2006
Here's a teaser:
I've got some data that forms a fairly complicated network. The
predicate <knows> needs to be symmetric. Can I get Redland to infer
using and OWL file that
<Bob> <knows> <Harry> .
from the fact that
<Harry> <knows> <Bob> . ?
Now if
<Harry> <knows> <Alice> .
<Alice> <knows> <Charles> .
Let's say I wish to know all the possible connections for people who are
once removed from each other. Using SPARQL I might ask:
SELECT ?person,?thirdperson WHERE
{ ?person <knows> ?secondperson .
?secondperson <knows> ?thirdperson .
}";
This will return:
?person ?thirdperson
Bob Alice
Bob Bob
Harry Charles
Harry Harry
The problem is that I don't know how to say that ?person may not be the
same as ?thirdperson. It is easy to add a ?person != ?thirdperson
requirement, but this becomes exceedingly awkward if I am looking for
links to a fourth, fifth, sixth person etc. Soon my query has as many !=
permutations as I am getting answers.
Using the DISTINCT keyword does not seem to help. Is there some function
of SPARQL that I am missing, or do I need to write my own algorithm to
use Redland's functions and exclude routes manually?
Thanks
Kieron
More information about the redland-dev
mailing list