Re: Question regarding subselect

On 30 Apr 2009, at 11:48, Simon Schenk wrote:
> If we do not add any features such as aggregates, scalar  
> expressions, assignment
> or similar - do subselects add anything to the expressiveness of the  
> language?
> All examples in the wiki include at least one such additional feature.
>
> Typical uses such as FORALL or EXISTS should be possible in the  
> current version
> of SPARQL using a combination of OPTIONAL, BOUND filters and perhaps  
> DISTINCT, I
> think.

There's nothing you couldn't do with multiple queries before. But, you  
can do new things using DISTINCT and LIMIT inside the subselect in one  
query, that's enough to do LimitByResource in many cases, which you  
can't do without SubSelects.

Example off the top of my head (may be incorrect):

SELECT *
WHERE {
   ?x a foaf:Person
   SUB {
     SELECT ?name
     WHERE { ?x foaf:name ?name }
     LIMIT 1
   }
   SUB {
     SELECT ?mbox
     WHERE { ?x foaf:mbox ?mbox }
     LIMIT 4
   }
}

Currently we don't implement sub queries, so we end up doing something  
like 20, where 1 would be fine.

- Steve

-- 
Steve Harris
Garlik Limited, 2 Sheen Road, Richmond, TW9 1AE, UK
+44(0)20 8973 2465  http://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 Thursday, 30 April 2009 12:46:29 UTC