OrientDB 查询语言中的传递闭包 [英] Transitive Clousure in OrientDB query language
本文介绍了OrientDB 查询语言中的传递闭包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个名为 PERSON 的顶点类和一个名为父亲的边类:
Suppose I have a vertex class called PERSON and and an edge Class called father:
CREATE CLASS PERSON EXTENDS V
CREATE CLASS father EXTENDS E
假设我用一些记录填充了 PERSON.我还用一些记录填充了父亲,这些记录将 PERSON 中的某些记录连接到 PERSON 的其他一些记录(这个简单的模型谁是谁的父亲)
Suppose that I populated PERSON with some records. I also populated father with some records that connect certain records in PERSON to some others records of PERSON (this simply model who is father of who)
我想知道以下查询在 OrientDB 中的样子?
I would like to know how the following query would look like in OrientDB?
找到Person 的所有祖先,比如p1(使用rid=#10:1)?
推荐答案
create class Person extends V
create class Father extends E
create vertex Person set name = 'grandfather' #12:0
create vertex Person set name = 'father' #12:1
create vertex Person set name = 'person' #12:2
create edge Father from #12:0 to #12:1
create edge Father from #12:1 to #12:2
我相信这就是上面描述的情况.您可以:
I believe this is the situation described above. You can:
select from (
traverse in('Father') from #12:2
) where @rid <> #12:2
这将返回人的所有祖先(#12:2).
This will return all the ancestors of the person (#12:2).
这篇关于OrientDB 查询语言中的传递闭包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文