W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > April to June 2009

Re: Question regarding subselect

From: Steve Harris <steve.harris@garlik.com>
Date: Thu, 30 Apr 2009 13:45:47 +0100
Cc: SPARQL Working Group <public-rdf-dawg@w3.org>
Message-Id: <6D854EB1-0686-476F-8B49-5DAB1F4B0CBE@garlik.com>
To: Simon Schenk <sschenk@uni-koblenz.de>
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:38 GMT