0

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)?

qartal
  • 2,024
  • 19
  • 31

1 Answers1

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).

vitorenesduarte
  • 1,579
  • 1
  • 8
  • 15