- From: <jos.deroo@agfa.com>
- Date: Wed, 8 Dec 2004 17:47:49 +0100
- To: andy.seaborne@hp.com
- Cc: RDF Data Access Working Group <public-rdf-dawg@w3.org>, public-rdf-dawg-request@w3.org
Andy, Thinking over it again, I've also done some trial code change.. We simulate GRAPH <dft.n3> <a.n3> <b.n3> as asserting following triples {:aRoot :q :a} q:source <dft.n3>. {:a :b :c} q:source <a.n3>. {:c :p :z} q:source <b.n3>. and translate Query 5 GRAPH <dft.n3> <a.n3> <b.n3> SELECT * WHERE SOURCE ?src1 ( ?x ?y ?z ) SOURCE ?src2 ( ?z ?r ?s ) into [] q:select {<> q:answer (?src1 ?x ?y ?z ?src2 ?r ?s)}; q:where {{?x ?y ?z} q:source ?src1. {?z ?r ?s} q:source ?src2}. to get following answers <file:/testQ.n3> q:answer (<file:/dft.n3> :aRoot :q :a <file:/a.n3> :b :c). <file:/testQ.n3> q:answer (<file:/a.n3> :a :b :c <file:/b.n3> :p :z). which concurs with your -------------------------------------------------- | src1 | x | y | z | src2 | r | s | ================================================== | <a.n3> | :a | :b | :c | <b.n3> | :p | :z | | <dft.n3> | :aRoot | :q | :a | <a.n3> | :b | :c | -------------------------------------------------- now will do some further tests.. -- Jos De Roo, AGFA http://www.agfa.com/w3c/jdroo/ "Seaborne, Andy" <andy.seaborne@hp.com> Sent by: public-rdf-dawg-request@w3.org 07/12/2004 12:02 Please respond to andy.seaborne To: RDF Data Access Working Group <public-rdf-dawg@w3.org> cc: (bcc: Jos De_Roo/AMDUS/MOR/Agfa-NV/BE/BAYER) Subject: Untrusted graphs - examples Some examples of untrusted graphs and queries. Dataset: === Default graph @prefix : <http://example.org/ns#> . :aRoot :q :a . === untrusted graph a.n3 @prefix : <http://example.org/ns#> . :a :b :c . === untrusted graph b.n3 @prefix : <http://example.org/ns#> . :c :p :z . ---- That is, a query starting with: FROM <dft.n3> GRAPH <a.n3> <b.n3> Note: there is a path a.n3/b.n3 via the :c node and a path default graph/a.n3 via the node :a Query 1: path of length 2: SELECT * WHERE ( ?x ?y ?z ) ( ?z ?r ?s ) Results: None. There is no merge of a.n3 and b.n3 nor a.n3/b.n3 into the default graph so there are no paths of length two to be found. The FROM/GRAPH need not be included - the query context may define the dataset as would be the case in many query services over large data collections. Query 2: SELECT * WHERE SOURCE ?src1 ( ?x ?y ?z ) SOURCE ?src2 ( ?z ?r ?s ) Results: -------------------------------------------------- | src1 | x | y | z | src2 | r | s | ================================================== | <a.n3> | :a | :b | :c | <b.n3> | :p | :z | -------------------------------------------------- One path, involving a.n3 and b.n3. The other path isn't found because the default graph isn't a named graph. Query 3: SELECT * WHERE ( ?x ?y ?z ) SOURCE ?src2 ( ?z ?r ?s ) Results: --------------------------------------- | x | y | z | src2 | r | s | ======================================= | :aRoot | :q | :a | <a.n3> | :b | :c | --------------------------------------- The first triple pattern accesses the default graph, not any of the named (untrusted) graphs. So there is one path, matching the first triple pattern in the default graph and the second in <a.n3> If the application does want paths involving the default graph and the untrusted graphs, then a way to do it is to give the default graph a name as an untrusted named graph as well: Query 4: FROM <dft.n3> GRAPH <dft.n3> <a.n3> <b.n3> SELECT * WHERE SOURCE ?src1 ( ?x ?y ?z ) SOURCE ?src2 ( ?z ?r ?s ) -------------------------------------------------- | src1 | x | y | z | src2 | r | s | ================================================== | <a.n3> | :a | :b | :c | <b.n3> | :p | :z | | <dft.n3> | :aRoot | :q | :a | <a.n3> | :b | :c | -------------------------------------------------- Query 5: which is the same Q4 because no non-SOURCE matches were done. GRAPH <dft.n3> <a.n3> <b.n3> SELECT * WHERE SOURCE ?src1 ( ?x ?y ?z ) SOURCE ?src2 ( ?z ?r ?s ) [These results were semi-automatically created - I haven't modified my parser but a one line change in the code causes graphs not to be merged so I just used that feature with a "named" default graph like Q5 then I had to tweak things to cover over the "named" default graph.] Andy
Received on Wednesday, 8 December 2004 16:49:17 UTC