I have done a family tree. I also defined transitive property: childOf. Now I want to make SPARQL Query which give me all descendants of one of members of family. How can I do it? Thanks
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If your triple store supports OWL reasoning and you've defined your childOf
property to be transitive (shouldn't it be called descendantOf
by the way!), then it should infer childOf
properties directly between all related nodes. So, it should be enough to query it like this (prefixes omitted for brevity):
SELECT DISTINCT * {
?x :childOf ?y
}
However, if your triple store doesn't do OWL reasoning, you can achieve the same result by using SPARQL 1.1 property paths to query for indirect relationships:
SELECT DISTINCT * {
?x :childOf+ ?y
}
Note the '+' after the childOf
, this means that the predicate may be matched 1 or more times. More details about SPARQL 1.1 property paths are at http://www.w3.org/TR/sparql11-property-paths/.