SPARQL: Delete instance and all of its properties with linked subproperties

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 05:21:25
Joshua Taylor

(even the possibly linked subproperties of observationSamplingTime, observationResultTime)?

Note that something like this pretty dangerous, since you might delete from triples from a context that you're not expecting to. E.g., suppose you had something like

:pointX :hasTime :time1 ;
        :hasValue :valueX .

:pointY :hasTime :time1 ;
        :hasValue :valueY .

:time1 :hasLabel "time1" .

If you "delete" :pointX, and recursively delete :time1, then you lose information that was important for :pointY as well. Remember that a triple store stores sets of triples. Things only exist by virtue of being a subject, predicate, or object.

At any rate, what you're trying to do isn't too hard. You can just do:

delete { ?s ?p ?o }
where {
  :thing (<>|!<>)* ?s . 
  ?s ?p ?o .
}

(<>|!<>)* is a wildcard path, so ?s gets bound to anything reachable from :thing, including :thing itself. ?p and ?o are just the property and object of ?s. For more information about the wildcard, see SPARQL: is there any path between two nodes?.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!