使用 OrientDB 你可以这样做:
create class Person extends V
create property Person.name string
create property Person.surname string
insert into Person(name, surname) values ("Barack","Obama")
create class Country extends V
create property Country.name string
insert into Country(name) values ("Hawaii")
create class was_born_in extends E
create edge was_born_in from (select from Person where name = "Barack") to (select from Country where name = "Hawaii")
这是这种情况:
+----+-----+-------+------+-------+---------------+--------------+
|# |@RID |@CLASS |name |surname|out_was_born_in|in_was_born_in|
+----+-----+-------+------+-------+---------------+--------------+
|0 |#17:0|Person |Barack|Obama |[#25:0] | |
|1 |#21:0|Country|Hawaii| | |[#25:0] |
+----+-----+-------+------+-------+---------------+--------------+
如果您运行此查询:
select expand(in('was_born_in')) from Country where name = "Hawaii"
你会得到所有住在夏威夷的人
+----+-----+------+------+-------+---------------+
|# |@RID |@CLASS|name |surname|out_was_born_in|
+----+-----+------+------+-------+---------------+
|0 |#17:0|Person|Barack|Obama |[#25:0] |
+----+-----+------+------+-------+---------------+
希望能帮助到你
问候