Transitive Clousure in OrientDB query language

杀马特。学长 韩版系。学妹 提交于 2019-12-25 03:36:18

问题


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 

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)

I would like to know how the following query would look like in OrientDB?

Find all ancestors of the Person, say p1 (with rid=#10:1)?


回答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

This will return all the ancestors of the person (#12:2).



来源:https://stackoverflow.com/questions/29973601/transitive-clousure-in-orientdb-query-language

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