W3C home > Mailing lists > Public > www-rdf-interest@w3.org > November 2003

RE: Semantic Web Phase 2 Activity - Protocol - Query Language

From: Graham Klyne <GK@ninebynine.org>
Date: Wed, 12 Nov 2003 10:51:47 +0000
Message-Id: <5.1.0.14.2.20031112102345.0320cea8@127.0.0.1>
To: "Seaborne, Andy" <Andy_Seaborne@hplb.hpl.hp.com>, "'Steve Harris'" <S.W.Harris@ecs.soton.ac.uk>, www-rdf-interest@w3.org

At 17:34 11/11/03 +0000, Seaborne, Andy wrote:

>Hi there - I have an example query with optional triples and I wondered what
>the various systems do with it:
>
>Thanks to Jeremy Carroll for this example.
>
>Consider the data:
>
><x> <p> <y> .
><x> <q> <z> .
>
>and the query:
>
>[ <x> <p> ?a ]
>[ <x> <q> ?a ]
>
>where [] is an optional match.
>
>?? Does the query match the data?
>?? What does it return?
>?? Does it matter whether it is constructing a graph or returning variable
>bindings?
>
>The issue is that the query binds a variable in the optional part but it
>can't be done consistently on the data.  It could match the first triple
>pattern and skip the second, it could also match the second but not the
>first but it can't match both.

My Python query software would return a match on the first option and 
no-match the second.  That is, ?a binds to <y>, and not to <z>.  If I 
returned a graph value (which I don't), the resulting graph would probably be:

   <x> <p> <y> .

I implement an optional section as having having alternative null 
match.  Alternative matching is a bit like if-then-else:  once the first 
part of an alternative is matched, use of the second (else) part is suppressed.

An different way would be to allow the matching system to backtrack after 
the first alternative has been matched, but I think that would have not 
been right for the application for which this was written.  (Hmmm... I 
think it's a bit like 'cut' in Prolog - handy but not so theoretically 
clean, since it introduces an asymmetry - or order-dependence - in the 
matching process.)

>PS Follow on problem - what if by inference <y> owl:sameAs <z> ?

I suppose that depends if you're querying a "physical" graph of an inferred 
graph.  In the latter case, I think the query would effectively be against 
an augmented graph, say:

<x> <p> <y> .
<x> <q> <z> .
<x> <q> <y> .

In which case a match is possible, with ?a bound to <y>.  The exact result 
depends on how one treats owl:sameAs ... is there a preferred approach when 
reasoning using a transitive closure style?  (I can't find any helpful owl 
test cases for this.)

Hmmm... that's interesting ... same variable binding as without owl:sameAs.

In this case, I think that if returning a graph rather than variable 
bindings, the resulting graph would be:

   <x> <p> <y> .
   <x> <q> <y> .

(i.e. both optional parts returned with appropriate substitutions.)

#g
--

>-------- Original Message --------
> > From: Steve Harris <mailto:S.W.Harris@ecs.soton.ac.uk>
> > Date: 11 November 2003 17:10
> >
> > On Tue, Nov 11, 2003 at 05:04:35 +0100, Leo Sauermann wrote:
> > > because from your answer I think you understood that i wanted to have
> > > some SQL standard stuff written in the Rdf-Query standard. Like "to
> > > implement a RDF-Query, you have to use these internal SQL queries"
> > > thats not what I meant, the OUTER JOIN problem is a RDF problem you
> > > have when you try to use RDQL (a very popular query language, imho).
> > > ...
> > > but with today's RDQL this is more complicated:
> > > if there is no <foaf:image> triple for leo, you don't get any data at
> > > all.
> >
> > Yes, agreed, this is a problem. I think that SQL behaviour is a LEFT
> > JOIN
> > though. I'm not sure how an OUTER JOIN would map to RDQL, but it
> > would probably give you more rows than that.
> > http://www.w3schools.com/sql/sql_join.asp
> >
> > - Steve

------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact
Received on Wednesday, 12 November 2003 06:50:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:52:03 GMT