W3C home > Mailing lists > Public > public-rdf-dawg-comments@w3.org > October 2005

Re: Traversing trees with sparql?

From: Richard Newman <r.newman@reading.ac.uk>
Date: Wed, 26 Oct 2005 22:42:36 +0100
Message-Id: <981D9E37-8C83-499D-A8B5-CF564B7001E9@reading.ac.uk>
Cc: public-rdf-dawg-comments@w3.org
To: Danny Ayers <danny.ayers@gmail.com>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:14:49 GMT