Sparql删除实体及其所有链接元素

时间:2017-03-07 16:29:06

标签: sparql fuseki

我有一个Fuseki数据库,其中包含以下三元组:

<https://tomcat.antudo.it/data/bucket.json-WSP1WS8#row=1>
<https://tomcat.antudo.it/data/bucket.json-WSP1WS8#ws7col0>
"ws6dat1aa"
...
<https://tomcat.antudo.it/data/bucket.json-WSP1WS8#row=2>
<https://tomcat.antudo.it/data/bucket.json-WSP1WS8#ws6col2>
"ws6dat2aa"
...
<http://www.w3.org/2002/07/owl#bottomDataProperty>
<http://www.w3.org/2002/07/owl#propertyDisjointWith>
<https://tomcat.antudo.it/data/bucket.json-WSP1WS8#ws7col0>

我想删除与以下相关的所有内容:

<https://tomcat.antudo.it/data/bucket.json-WSP1WS8#row=1>

问题在于,我无法编写同样针对三元组的查询:

<http://www.w3.org/2002/07/owl#bottomDataProperty>
<http://www.w3.org/2002/07/owl#propertyDisjointWith>
<https://tomcat.antudo.it/data/bucket.json-WSP1WS8#ws7col0>

我使用以下查询删除有关实体列表的三元组:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
DELETE { 
  ?x ?y ?z
} 
WHERE { 
  {
   ?x ?y ?z.
   ?x rdfs:seeAlso <https://tomcat.antudo.it/data/#dcat_test.csv-WSP1WS6>.
  }
  union
    {
   ?x ?y ?z.
   ?x rdfs:seeAlso <https://tomcat.antudo.it/data/#dcat_test.csv-WSP1WS7>.
  }
}

我想我必须做类似的事情: SPARQL: Delete instance and all of its properties with linked subproperties但我被困住了。任何帮助将不胜感激

1 个答案:

答案 0 :(得分:2)

如果要完全从图表中删除资源,则以下内容应该有效。请注意,您需要删除三元组&#34;两种方式&#34;。

DELETE { 
  <https://tomcat.antudo.it/data/bucket.json-WSP1WS8#row=1> ?p ?o .
  ?s1 ?p1 <https://tomcat.antudo.it/data/bucket.json-WSP1WS8#row=1> .
} 
WHERE { 
   <https://tomcat.antudo.it/data/bucket.json-WSP1WS8#row=1> ?p ?o .
   OPTIONAL {
      ?s1 ?p1 <https://tomcat.antudo.it/data/bucket.json-WSP1WS8#row=1> .
   }
}