Re: [sub-select] Some examples and discussion

On 11 Mar 2009, at 11:10, Seaborne, Andy wrote:

> In the telecom yesterday, the chair suggested progressing technical  
> discussions to the mailing list.  Here's some more examples for sub- 
> selects and some discussion points.
...

> This query finds people who know 10 or more other people and returns  
> the RDF term for them.
>
> ## Find people who know 10 or more others
> PREFIX  :     <http://example/>
> PREFIX  foaf: <http://xmlns.com/foaf/0.1/>
>
> SELECT  ?x
> WHERE
>  { ?x foaf:knows ?z}
> GROUP BY ?x
> HAVING (count(*) >= 10 )
>
> using sub-select, the returned collection of resources for people  
> can be used further
> (like all these examples, there may be other ways of addressing the  
> task - they are just examples)
>
> ## Names of people
> PREFIX  :     <http://example/>
> PREFIX  foaf: <http://xmlns.com/foaf/0.1/>
>
> SELECT  ?x ?n
> WHERE
>  { ?x foaf:name ?name
>    { SELECT  ?x
>      WHERE
>        { ?x foaf:knows ?z}
>      GROUP BY ?x
>      HAVING ( count(*) >= 10 )
>    }
>  }

This compositionality is one of the things I really like about  
subselects. I believe that it makes the language easier to learn, as  
opposed to having explicit syntax to handle the aggregate functions.  
It's also a familiar trope to SQL users.

I don't quite agree that just having subselects on their own delivers  
nothing, just the use of ORDER BY and LIMIT allows you to do things  
you can't do in SPARQL 1.0. Certainly projected expressions and  
aggregate functions make it a lot more useful however.

- Steve

-- 
Steve Harris
Garlik Limited
2 Sheen Road
Richmond  TW9 1AE

T   +44(0)20 8973 2465
F   +44(0)20 8973 2301
www.garlik.com

Registered in England and Wales 535 7233 VAT # 849 0517 11
Registered office: Thames House, Portsmouth Road, Esher, Surrey, KT10  
9AD

Received on Wednesday, 11 March 2009 11:44:49 UTC