*updated join query so that it doesn't include animals that don't have a person.
If you are using the graph database you can do the following:
create class person extends V
create class animal extends V
create class animals extends E
create vertex animal set name='Max',species='dog'
create vertex animal set name='Lulu',species='cat'
create vertex animal set name='zigzag',species='snake'
create vertex person set name="John"
create edge animals from ( select from person ) to ( select from animal where name in ["Max","Lulu"] )
select @rid as animal_rid, in('animals')[0].name as pn, name from animal where in('animals').size() <> 0
----+-----+----------+----+------
# |@RID |animal_rid|pn |name
----+-----+----------+----+------
0 |#-2:1|#13:1 |John|Max
1 |#-2:2|#13:2 |John|Lulu
The @RID is not a real rid but you can get it from the @rid field.
in('animals') is a function that follows the in_animals property on the record and results in a collection. You can get the first item in the collection using [0] (note the "first" function should also work but unfortunately using it limits the results to one record instead of just the first item of the collection field... I think that's a bug).
For the "cross join" if you are using it like an inner join then it's
the same as above. If it's a real cross join, I'm not sure how to do
that.
To add an edge using the graph database:
create edge animals from ( select from person where name = 'John' ) to ( select from animal where name='zigzag' )