- From: Seaborne, Andy <andy.seaborne@hp.com>
- Date: Sun, 07 Nov 2004 17:57:54 +0000
- To: Ivan Herman <ivan@w3.org>
- Cc: public-rdf-dawg-comments@w3.org
Ivan Herman wrote: > Andy, > > thanks for the reply. Some (small) answer/remarks below > > Seaborne, Andy wrote: > <snip/> >> >> This is an area where the working draft says very little and it is being >> worked on at the moment. >> >> Constraints, like triple patterns, are restrictions on the results that >> match the query. For any match, there is a set of bindings and >> constraints evaluated on these function must be true. >> >> A function will receive its variables as arguments (and the variables >> may be unbound due to optional, say - the function will have to cope). >> The actual mechanism for doing that will be implementation dependent - >> executing all the constraints after the triple pattern matching would be >> correct but may be slower than executing a constraints as soon as its >> variables can be bound, e.g., just after the point where all varibales >> used have been mentioned in patterns as per your per-pattern >> constraints. As a query engine may choose to match the triple patterns >> in any order, or in groups, there is lots of scope for implementation >> optimization here. >> > > Understood. Actually, this is in line with what I implemented: on the > 'engine' level there is a possibility to call a constraint method per > triplets as well as for global, and an SQRL parser may optimize by > choosing the former when appropriate Yes - there is a large body of work on data flow analysis that some engines may usefully dip into. > > >> >>> --------------- >>> >>> Nested Patterns. It is not clear in the draft how 'deep' nesting can >>> go. I did only the simple one, ie, only a one level depth is managed: >>> >>> (?a,?b,c), {(?q,?w?,?r),(?s,t,?u)} >>> >>> It is not clear whether a nesting of the kind: >>> >>> (?a,?b,c), {(?q,?w?,?r),{(?s,t,?u),(?q,k,?o)}} >>> >>> is also allowed or not. Actually, if it is, it has to be defined what >>> it really *means*. >> >> >> >> In that example, it is all conjunction and the same as: >> >> (?a,?b,c) (?q,?w?,?r) (?s,t,?u) (?q,k,?o) >> >> > > > Then I am lost.:-( My understanding was that (just referring to Ti-s for > triples): > > [T1 {T2 T3}] means [T1 T2] OR [T1 T2] > Clarification first - [] is optional matching. > so why would > > [T1 {T2 {T3 T4}}] mean [T1 T2 T3 T4] as you write? What is then the > difference between > > [T1 {T2 {T3 T4}}] and [T1 {T2 T3 T4}] or indeed [T1 T2 T3 T4]? Nothing because the {} is just a set of triple patterns and juxaposition is conjunction so T1 {T2 {T3 T4}} is "T1 AND (T2 AND (T3 AND T4))" which is the same as the other forms. > > My interpretation of [T1 {T2 {T3 T4}}] would be > > > [T1 T2] OR [T1 T3 T4] > > what am I missing? > >> >>> (My initial thoughts are that it means an >>> alternation of 'or'-s and 'and'-s, it means >>> (?a,?b,c) and (?q,?w?,?r) >>> or >>> (?a,?b,c) and (?s,t,?u) and (?q,k,?o) >>> >>> etc, recursively.) If this is adopted, it has to be described. >> >> >> >> Noted. >> >> >>> ----------------- >>> >>> Optional Patterns. I was not clear to me *why* there might be more >> >> >> than >> >>> one optional patterns, whereas there is only *one* where pattern. Why >>> the asymmetry? >> >> >> >> There may be more than one optional because there may be indendent >> optionalk information: >> >> PREFIX foaf: <http://xmlns.com/foaf/0.1/> >> SELECT ?name ?mbox ?hpage >> WHERE ( ?x foaf:name ?name ) >> [ ( ?x foaf:mbox ?mbox ) ] >> [ ( ?x foaf:homepage ?hpage ) ] >> >> Here, "mbox" and "hpage" get added to the results independently of each >> other. >> > > I presume you meant > > PREFIX foaf: <http://xmlns.com/foaf/0.1/> > > SELECT ?name ?mbox ?hpage > > WHERE ( ?x foaf:name ?name ) > > OPTIONAL [ ( ?x foaf:mbox ?mbox ) ] > > [ ( ?x foaf:homepage ?hpage ) ] Not quite : [] is the optional block itself not merely statement grouping. OPTIONAL { T1 T2 } is the same as [ T1 T2 ] > > but is the difference between that and > > PREFIX foaf: <http://xmlns.com/foaf/0.1/> > SELECT ?name ?mbox ?hpage > WHERE ( ?x c ?name ) > OPTIONAL { ( ?x foaf:mbox ?mbox ) ( ?x foaf:homepage ?hpage ) } Consider the dataset: _:a foaf:name "Sally" . _:a foaf:mbox <mailto:ceo@example.org> . then PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?mbox ?hpage WHERE ( ?x foaf:name ?name ) [ ( ?x foaf:mbox ?mbox ) ] [ ( ?x foaf:homepage ?hpage ) ] has a solution: ?name = "Sally" ?mbox=<mailto:ceo@example.org> ?hpage unset whereas: OPTIONAL { ( ?x foaf:mbox ?mbox ) ( ?x foaf:homepage ?hpage ) } requires both triples to match in order to match so the solution is: ?name = "Sally" ?mbox unset ?hpage unset It would not have a solution with just ?mbox bound because to match { T1 T2 } both T1 and T2 must match. I hope that is a bit clearer. <snip/> Andy
Received on Sunday, 7 November 2004 17:58:29 UTC