- From: Patrick Stickler <patrick.stickler@nokia.com>
- Date: Thu, 13 Nov 2003 10:34:08 +0200
- To: <www-rdf-interest@w3.org>
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? Well, it's a very odd query to begin with. What I understand this to actually be asking is, which resources have a value defined either for property 'p' or for property 'q'. Since both are optional, you are not constraining the match to p = q nor restricting either p or q from having any other value defined. RDFQ doesn't allow this kind of ambiguity. In RDFQ, this would have to be expressed as two separate targets (where every target is by definition an optional match). E.g. [:target [ex:p []]] [:target [ex:q []]] which would return descriptions of all targets which have a value defined for p and all targets which have a value defined for q. If for a given target, p = q, so what. The query isn't really asking that. Now you could include an explicit id for each value [1], e.g. [:target [ex:p [:id "a"]]] [:target [ex:q [:id "a"]]] But that would have no affect on the results. However, if the equality of the values of p and q were not optional, i.e. [:target [ex:p [:id "a"]; ex:q [:id "a"]]] then only those targets having some value defined for p and q where the value for p and q is the same would be described in the results. If you wanted to make only e.g. q optional, you'd just specify [:target [ex:p]] What you can't express in RDFQ is a template that matches a target that has some value defined for p and either the same value defined for q or no value defined for q. I.e. [:target [ex:p [:id "a"]; ex:q ( [:id "a"] OR :null ) ]] (which is not legal RDFQ). Cheers, Patrick [1] rdfq:id is not presently defined in the currently published RDFQ spec, but is part of the current design.
Received on Thursday, 13 November 2003 03:36:46 UTC