W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > July to September 2010

Re: limit per resource rethought...

From: Steve Harris <steve.harris@garlik.com>
Date: Wed, 11 Aug 2010 11:23:15 +0100
Cc: SPARQL Working Group <public-rdf-dawg@w3.org>
Message-Id: <1E35E4DA-7334-455A-B1CB-0D731340A6A6@garlik.com>
To: Axel Polleres <axel.polleres@deri.org>
On 2010-08-11, at 10:56, Axel Polleres wrote:

> Hi all again,
> 
> in the course of my last mail, I also thought about adding another example:
> 
> E)  "Give me all persons and the first 3 (alphabetically by name) of their friends"
> 
> but I couldn't find any way to write this in an intuitive manner... ideas anyone? 
> I am afraid, that - by the scoping we have imposed for subqueries - that one might be difficult/impossible? 
> 
> The following naive writing  does't work obviously:
> 
>  SELECT ?P ?F
>  { ?P a :Person . 
>    {SELECT ?P ?F { ?P :knows ?F . ?F name ?N } ORDER BY ?N LIMIT 3 }
>  }
> 
> I also think I recall that we had this discussion already some time back in some other form,
> but I can't recall the outcome :-| 

This doesn't work because bindings happen bottom up, so the subSELECT is bound before the outer SELECT, I find this counter-intuative, but there are technical reasons why it has to be that way round, as I understand it.

Another thing that also doesn't quite work is:

SELECT ?p (SAMPLE(?f) AS ?f1) (SAMPLE(?f) AS ?f2) (SAMPLE(?f) AS ?f3)
WHERE {
   ?p a :Person .
   ?p :knows ?f .
} GROUP BY ?p

The problem is that by the definition of the Sample set function, you get the same binding of ?f each time.

We could have a form of SAMPLE() like SAMPLE(?var ; offset=N), which takes the Nth value, rather than the 0th. 

- Steve

PS look, no commas :)

-- 
Steve Harris, CTO, Garlik Limited
1-3 Halford Road, Richmond, TW10 6AW, UK
+44 20 8439 8203  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 Wednesday, 11 August 2010 10:23:50 GMT

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