Re: Example updates

On 3 Dec 2009, at 01:44, Paul Gearon wrote:

> On Wed, Dec 2, 2009 at 6:32 AM, Steve Harris  
> <steve.harris@garlik.com> wrote:
>> On 1 Dec 2009, at 21:06, Paul Gearon wrote:
>>
>>> The main question on updates seems to be around referring to  
>>> multiple
>>> graphs, so these operations are based on that idea. I'll be using  
>>> some
>>> common prefixes (foaf:, contact:), so I hope no one minds if I don't
>>> define them.
>>>
>>> I can't recall if I'm supposed to be writing according to a specific
>>> syntax, so I'll offer a couple of variations.
>>>
>>> The first case has one source for pattern matching, and one
>>> destination for insertion.
>>> This example copies the contents of one graph into another.
>>>
>>> (1) The original form would be:
>>>
>>> INSERT INTO <destination> { ?s ?p ?o }
>>> WHERE { GRAPH <source> { ?s ?p ?o } }
>>>
>>> (2) With the recent changes:
>>>
>>> WITH <source>
>>> INSERT INTO <destination> { ?s ?p ?o }
>>> WHERE { ?s ?p ?o }
>>>
>>>
>>> (3) Or using GRAPH instead of INTO:
>>>
>>> WITH <source>
>>> INSERT { GRAPH <destination> { ?s ?p ?o } }
>>> WHERE { ?s ?p ?o }
>>
>> So, in this case wouldn't INSERT ... FROM be a perfectly reasonable  
>> thing to
>> write? It would have the same meaning as in SELECT, wouldn't it?
>
> I'm not sure where you're going here.
>
> Are you suggesting using FROM to indicate what the WHERE clause should
> be resolved against? If so, then sure. However, the advantage of WITH
> is that it also applies to INSERT and DELETE where no graph is
> supplied. In that case, the word "FROM" isn't appropriate. WITH is a
> little more general, even if it's not very pretty.

Ah, I see, I think.

...
>> Wouldn't
>>
>> DELETE {
>>  GRAPH <a> { ?person foaf:mbox ?email }
>>  GRAPH <b> { ?person foaf:mbox ?email }
>>  GRAPH <c> { ?person foaf:mbox ?email }
>> }
>> INSERT { ?person foaf:mbox ?email }
>> WHERE {
>>  GRAPH <a> {?person foaf:mbox ?email}
>>  UNION GRAPH <b> {?person foaf:mbox ?email}
>>  UNION GRAPH <c> {?person foaf:mbox ?email}
>> }
>>
>> do the job?
>
> Yes it would, and I was tempted to write it as such. But since this
> variation has the option of using "WITH", then I figured I should
> shoe-horn it into the example. Besides, the following variation drops
> the WITH, and I wanted to show that there could be a difference
> between the two.

OK, makes sense.

> I'm expecting that WITH (or USING... I still like that word), will be
> useful when the majority of the INSERTs, DELETEs and pattern matching
> happen on a single graph. This example is the opposite of that
> situation, so it doesn't show the potential benefits.
>
>>> (4)
>>> DELETE { GRAPH <a> { ?person foaf:mbox ?email } };
>>> DELETE { GRAPH <b> { ?person foaf:mbox ?email } };
>>> DELETE { GRAPH <c> { ?person foaf:mbox ?email } };
>>> INSERT { GRAPH <email_graph> {?person foaf:mbox ?email } }
>>> WHERE {
>>>  GRAPH <a> {?person foaf:mbox ?email}
>>>  UNION GRAPH <b> {?person foaf:mbox ?email}
>>>  UNION GRAPH <c> {?person foaf:mbox ?email}
>>> }
>>>
>>>
>>> Alternatively, instead of the union it could be something like:
>>> DELETE { GRAPH <?g> { ?person foaf:mbox ?email } };
>>> INSERT { GRAPH <email_graph> {?person foaf:mbox ?email } }
>>> WHERE {
>>>  GRAPH <?g> {?person foaf:mbox ?email} .
>>>  FILTER (?g == <a> || ?g == <b> || ?g == <c>)
>>> }
>>
>> s/<?g>/?g/
>
> Yes, thanks.
>
>>> This example has a single source for pattern matching, and multiple
>>> destinations for insertion:
>>>
>>> (1) not possible
>>>
>>> (2)
>>> WITH <people_graph>
>>> INSERT INTO <email_graph> {?person foaf:mbox ?email };
>>> INSERT INTO <name_graph> {?person foaf:name ?name }
>>> WHERE {
>>>  ?person a foaf:Person
>>>  OPTIONAL { ?person foaf:mbox ?email }
>>>  OPTIONAL { ?person foaf:name ?name }
>>> }
>>
>> Surely variable bindings don't span the ; ?
>
> I expected them to come out of the WHERE, so yes, they do. The only
> binding that occurs in the above example is in the WHERE clause. The
> INSERTs are just using an already bound set of variables.

To me that seems very strange.

- Steve

-- 
Steve Harris, CTO, 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, 3 December 2009 10:58:01 UTC