0

I'm trying to understand blank nodes in turtle correctly, and I need to know if I have understood them correctly.

Suppose we had a turtle file:

@prefix sn: <....some uri...> .
_:a sn:name "person1";
sn:email "email1@test.com" .
_:b sn:name "person2";
sn:email "email2@test.com" .
_:c sn:name "person3" .

and we have SPARQL query:

PREFIX sn: <...some uri...>
SELECT ?email WHERE {
?x sn:name "person1" .
?x sn:email ?email .
}

This would only return the email of person 1, because ?x binds to the blank node label _:a... So my question is if an undefined variable ?x can still bind to a blank node that has a label, just like it would if it was not blank... So in this example, return will be:

      email
--------------------------
<mailto:email1@test.com> |

Would that be correct? Thanks.

4

1 に答える 1

1

あなたは正しく推測します: どちらの場合も (そして、私はあなたの 2 つの例の違いを実際には見ていないと言ったように)、答えは人 1 の電子メールだけになります.

空白ノードは、SPARQL の観点からは、他のリソースと同様にリソースであり、まったく同じ方法で変数を空白ノードにバインドします。上記の例では、2 つのステートメントが同じ空白ノードをサブジェクトとして使用していることがわかっているため (同じラベルを使用しているため)、SPARQL からは同じサブジェクトに関するものとして認識されます。

1 つの注意点: 使用する SPARQL エンジン/トリプルストアは、特定の空白のノード ID を保持しない可能性が高いですa: データをトリプルストアに追加すると、生成された内部 ID に置き換えられます。ただし、もちろん、トリプルストアはa、ファイル内の両方の出現が、まったく同じ生成された ID に置き換えられることを確認します。

于 2015-12-09T20:17:33.790 に答える