Re: bc inferencing on optional query patterns

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]

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 Thursday, 19 August 2004 08:22:08 UTC