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

Re: MINUS

From: Andy Seaborne <andy.seaborne@talis.com>
Date: Tue, 18 May 2010 14:42:51 +0100
Message-ID: <4BF2995B.3000206@talis.com>
To: Olivier Corby <Olivier.Corby@sophia.inria.fr>
CC: SPARQL Working Group <public-rdf-dawg@w3.org>
Mechanical answer: I calculated it as:

==== D.ttl

@prefix i: <http://example/> .
@prefix n: <http://example/ns#> .

i:Jules n:memberOf  i:abc .
i:Jules n:related        i:Jim .
i:Jim    n:memberOf i:def .

=== Q.arq
prefix i: <http://example/>
prefix n: <http://example/ns#>

select * where {
     ?x n:memberOf ?org .
     {{?x n:related ?y} minus {?y n:memberOf ?org}}
}
===
which is:
(prefix ((n: <http://example/ns#>)
          (i: <http://example/>))
   (join
     (bgp (triple ?x n:memberOf ?org))
     (minus
       (bgp (triple ?x n:related ?y))
       (bgp (triple ?y n:memberOf ?org)))))

 >> arq.sparql --engine=ref --data D.ttl --query Q.arq
---------------
| x | org | y |
===============
---------------

because LHS of MINUS:

prefix i: <http://example/>
prefix n: <http://example/ns#>
SELECT * {?x n:related ?y}
==>
-------------------
| x       | y     |
===================
| i:Jules | i:Jim |
-------------------

and RHS of MINUS
prefix i: <http://example/>
prefix n: <http://example/ns#>
SELECT * {?y n:memberOf ?org}
==>

-------------------
| y       | org   |
===================
| i:Jim   | i:def |
| i:Jules | i:abc |
-------------------

so ?y=i:Jim in the LHS is in the RHS of the MINUS and so that row is 
removed from the results.

The join with ?x n:memberOf ?org . is joining with the empty table so is 
empty.

----

What did you expect?  What was the thought behind the question?

	Andy

LHS = Left Hand Side
RHS = Right Hand Side

On 18/05/2010 1:57 PM, Olivier Corby wrote:
> What is the result of this query ?
>
> i:Jules n:memberOf i:abc
> i:Jules n:related i:Jim
> i:Jim n:memberOf i:def
>
> select * where {
> ?x n:memberOf ?org .
> {{?x n:related ?y} minus {?y n:memberOf ?org}}
> }
>
>
>
> Olivier
>
>
>
>
> Please consider the environment before printing this email.
>
> Find out more about Talis at http://www.talis.com/
> shared innovation™
>
> Any views or personal opinions expressed within this email may not be
> those of Talis Information Ltd or its employees. The content of this
> email message and any files that may be attached are confidential, and
> for the usage of the intended recipient only. If you are not the
> intended recipient, then please return this message to the sender and
> delete it. Any use of this e-mail by an unauthorised recipient is
> prohibited.
>
> Talis Information Ltd is a member of the Talis Group of companies and is
> registered in England No 3638278 with its registered office at Knights
> Court, Solihull Parkway, Birmingham Business Park, B37 7YB.
Received on Tuesday, 18 May 2010 13:43:25 GMT

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