Re: Traversing trees with sparql?

What SPARQL lacks is any way to say "and keep going" without  
repeatedly (recursively!) asking additional queries. E.g., traversing  
a social network via foaf:knows, or scooping up the whole transitive  
closure of rdf:type/rdfs:subClassOf, is impossible* without multiple  
queries.

What I really mean here, of course, is "transiting"** rather than  
"transitive" -- as with a social network, it is not the case that:

x knows y
y knows z
=>
x knows z

... but we do want to run a query for the path expression which, in  
Ivanhoe, would be (:rep+ !foaf:knows).

If we had some addition on top of SPARQL that returned these bindings:

x    |     y
============
a    |     b
b    |     c
b    |     d
c    |     e
...

for a tree:

a narrower b .
b narrower c, d .
c narrower e .

Then we can do the work on the client with only one query to get the  
data.

The point about pruning the tree still stands, of course :)

Working with actual transitive closures is a related point.

-R

* unless, of course, the SPARQL endpoint is sitting on top of a  
properly-loaded inferencing store.
** warning: made up word.


On 26 Oct 2005, at 22:28, Danny Ayers wrote:

>
> On 10/26/05, Richard Newman <r.newman@reading.ac.uk> wrote:
>
>
>> If SPARQL supported transitive properties, it would be fairly
>> straightforward to dump the tree structure with one query*, then cut
>> it down on the client and issue one big DESCRIBE query with all of
>> the desired nodes.
>>
>
>
>> * e.g. SELECT ?x ?y WHERE { ?x dmoz:narrow ?y . } WITH TRANSITIVE
>> ( dmoz:narrow )
>>
>
> I assume you're describing a Lisp style of recursion  (I'm loath to
> say that in ignorance, but that Lisp book I ordered hasn't yet arrived
> ;-). If that's near enough, what I don't really get is how 1. the
> transitivity is an especially useful special case of the rules; 2. how
> you deal with the closure thing, i.e. how do you do the bounds on such
> an operator?

Received on Wednesday, 26 October 2005 21:43:11 UTC