W3C home > Mailing lists > Public > www-rdf-interest@w3.org > August 2004

RE: bc inferencing on optional query patterns

From: Seaborne, Andy <andy.seaborne@hp.com>
Date: Tue, 24 Aug 2004 10:49:27 +0100
Message-ID: <E864E95CB35C1C46B72FEA0626A2E80803E3BF3D@0-mail-br1.hpl.hp.com>
To: Steve Harris <S.W.Harris@ecs.soton.ac.uk>, www-rdf-interest@w3.org




-------- Original Message --------
> From: Steve Harris <>
> Date: 19 August 2004 09:22
> 
> Hi Phil,
> 
> On Thu, Aug 19, 2004 at 07:45:56 +0100, phil@phildawes.net wrote:
> > E.g. take the following query, which gets all http://example.com/foo's
> > props and objects, and if the object is a resource also gets an
> > rdfs:label for it: 
> > 
> > select ?obj, objlabel
> > where    (<http://example.com/foo> ?prop ?obj)
> > OPTIONAL (?obj rdfs:label ?objlabel)
> > 
> > I want to do subproperty inferencing on the optional pattern to return
> > e.g. foaf:name labels (foaf:name is a subproperty of rdfs:label).
> > As in the 3store paper[1], I am using the idiom:
> > 
> > ?subj ?prop ?obj
> > ->
> > ?subj ?tmp ?obj
> > ?tmp SUBPROPERTYOF ?prop
> > 
> > 
> > But that yields:
> > 
> > select ?obj, ?objlabel
> > where    (<http://example.com/foo> ?prop ?obj)
> > OPTIONAL (?obj ?tmp ?objlabel)
> > OPTIONAL (?tmp rdfs:subPropertyOf rdfs:label)
> 
> I think it actually becomes:
> 
> select ?obj, ?objlabel
> where    (<http://example.com/foo> ?prop ?obj)
> OPTIONAL (?obj ?tmp ?objlabel)
>          (?tmp rdfs:subPropertyOf rdfs:label)
> 
> an optional subgraph, c.f. http://www.w3.org/2001/sw/DataAccess/tests/
> but that still breaks the rule of having variables that can only be
> bound 
> in the optional part, but can, I think be expanded to something like:
> [using SQL+RDF and a subset of 3stores schema]

The rule I think is needed is that a variable can't be bound in two separate
OPTIONALs - that causes the non-deterministic behaviour that Phil noted.
Variables can be bound in OPTIONALs (that's the point of them!) and binding
twice in one match is fine.  Its the whole OPTIONAL block that
matches/doesn't match.

	Andy

PS The new syntax is a bit clearer that there is one optional block in that
query.

 SELECT ?obj, ?objlabel
 WHERE  { <http://example.com/foo> ?prop ?obj . }
 OPTIONAL
        { ?obj ?tmp ?objlabel .
          ?tmp rdfs:subPropertyOf rdfs:label }




> 
> SELECT t1.object, t2.object
> FROM triples t1
> LEFT JOIN triples t2 ON
>       (t2.subject = t1.object)
> LEFT JOIN triples t3 ON
>       (t3.subject = t2.predicate AND
>        t3.predicate = <rdfs:subPropertyOf> AND
>        t3.object = <rdfs:label>)
> WHERE t1.subject = <http://example.com/foo>
> 
> - Steve
Received on Tuesday, 24 August 2004 09:50:03 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:14:57 UTC