是否可以将这 2 个 SPARQL INSERT 合并为一个? [英] Is it possible to combine those 2 SPARQL INSERT into one?

查看:39
本文介绍了是否可以将这 2 个 SPARQL INSERT 合并为一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行以下查询,在节点 a 和节点 b 之间添加关系 skos:related :

I want to perform the following queries, to add a relation skos:related between node a and node b :

  PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
  INSERT { GRAPH ?graph { ?a skos:related ?b } }
  WHERE{
    GRAPH ?graph {
      { ?a skos:inScheme ?scheme } .
      { ?b skos:inScheme ?scheme }
    }
 };
 INSERT { GRAPH ?graph { ?b skos:related ?a } }
 WHERE{
   GRAPH ?graph {
     { ?a skos:inScheme ?scheme } .
     { ?b skos:inScheme ?scheme }
   }
 };

我更愿意向 RDF 存储发送单个查询,但找不到这样做的方法.显然,这里的查询采用通用形式,并且 ?a、?b、?scheme 和 ?graph 变量在执行时与特定值绑定.

I would prefer to send a single query to the RDF store, but can't find a way to do so. Obviously, the queries are here in generic form, and ?a, ?b, ?scheme and ?graph variables are bound with specific values at execution.

有办法吗?

推荐答案

您不能在单个查询模式中同时断言 skos:related 关系的两个方向吗?即:

Can't you just assert both directions of the skos:related relation in a single query pattern? I.e.:

PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
INSERT { GRAPH ?graph { ?a skos:related ?b . ?b skos:related ?a } }
WHERE{
  GRAPH ?graph {
    { ?a skos:inScheme ?scheme } .
    { ?b skos:inScheme ?scheme }
  }
};

这篇关于是否可以将这 2 个 SPARQL INSERT 合并为一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆