W3C home > Mailing lists > Public > public-rdf-dawg-comments@w3.org > December 2007

Re: Simple example of need for negation operator

From: Lee Feigenbaum <lee@thefigtrees.net>
Date: Tue, 11 Dec 2007 09:52:36 -0500
Message-ID: <475EA434.8020500@thefigtrees.net>
To: Adrian Walker <adriandwalker@gmail.com>
CC: public-rdf-dawg-comments@w3.org

Some can, like min and max. Most can't, as far as I know.

See http://lists.w3.org/Archives/Public/public-rdf-dawg/2007OctDec/0078.html

Lee

Adrian Walker wrote:
> Lee --
> 
> Is there perhaps some similar SPARQL workaround to get aggregation? 
> 
> That would be: count rows, count symbols, sum, max, min, and avg.
> 
>                                   Thanks,  -- Adrian
>                 
> Internet Business Logic
> A Wiki and SOA Endpoint for Executable Open Vocabulary English
> Online at www.reengineeringllc.com <http://www.reengineeringllc.com>    
> Shared use is free
> 
> Adrian Walker
> Reengineering
> 
> On 12/11/07, *Lee Feigenbaum* <lee@thefigtrees.net 
> <mailto:lee@thefigtrees.net>> wrote:
> 
> 
>     Bob MacGregor wrote:
>      > Once upon a time, there was speculation that the the combination of
>      > SPARQL's OPTIONAL and UNBOUND
>      > operators are adequate to emulate a negation-as-failure operator.
>      > Previously, we produced examples
>      > that contradicted that claim.   Here is another such example,
>     which is
>      > relatively simple, of a query that
>      > (I believe) one cannot express in SPARQL.  It comes out of a real
>      > application we are implementing for a client, i.e.,
>      > its a use case.
>      >
>      > The application involves attaching tags to resources that specify the
>      > time of first use.  In other words,
>      > until the time specified has passed, the resource should not be
>      > retrievable.  In the application, updates
>      > are distributed across triple stores, and the tags serve to
>     insure that
>      > newly updated resources will be visible
>      > at the same time across the distributed stores.  It can happen
>     that a
>      > resource is tagged more
>      > than once (since it may be updated more than once).  Below is a query
>      > that retrieves only Articles
>      > such that none of their time tags has a newer time than the present
>      > (phrased in a SPARQL-like
>      > syntax):
>      >
>      > SELECT ?a
>      > FROM model
>      > WHERE
>      >      (?a rdf:type ft:Article) AND
>      >      UNSAID ((?a ex:timetag ?time) AND
>      >                    (?time > $NOW))
>      >
>      > This query can also be phrased without difficulty in SQL.  If anyone
>      > knows how to
>      > express this in SPARQL, I'd like to see the solution.
> 
>     Hi Bob,
> 
>     In SPARQL, this query is (unedited, untested):
> 
>     SELECT ?a
>     FROM :model
>     WHERE {
>        ?a rdf:type ft:article ; ex:timetag ?maxtime .
>        OPTIONAL { ?a ex:timetag ?othertime . FILTER(?othertime > ?maxtime) }
>        FILTER (!bound(?othertime) && ?maxtime > '...now...')
>     }
> 
>     Negation / universal quantification is not pretty in SPARQL, but it can
>     usually be done.
> 
>     I'm CC'ing public-sparql-dev@w3.org
>     <mailto:public-sparql-dev@w3.org>, which is a more appropriate list
>     for 'how-to' questions about SPARQL.
> 
>     thanks,
>     Lee
> 
> 
Received on Tuesday, 11 December 2007 14:52:55 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:14:52 GMT