据我所知,在图形数据库中,关系是在插入后创建的,而不是字段到字段关系,它们是记录到记录的关系。如果我的理解是正确的,那么当我从CSV文件导入一百万条记录并需要将它们与另一个表中的记录相关联时,我需要做什么?
在插入之前设计时关系(边缘)是不可能的,这样无论何时插入记录,它都已经存在关系了吗?
我的数据库详述如下。
create class Country extends V
create class Immigrant extends V
create class comesFrom extends E
create property Country.c_id integer
create property Country.c_name String
create property Immigrant.i_id integer
create property Immigrant.i_name String
create property Immigrant.i_country Integer
如果我手动创建边缘,它将是这样的。
insert into Country(c_id, c_name) values (1, 'USA')
insert into Country(c_id, c_name) values (2, 'UK')
insert into Country(c_id, c_name) values (3,'PAK')
insert into Immigrant(i_id, i_name,i_country) values (1, 'John',1)
insert into Immigrant(i_id, i_name,i_country) values (2, 'Graham',2)
insert into Immigrant(i_id, i_name,i_country) values (3, 'Ali',3)
create edge comesFrom from (select from Immigrant where i_country = 1) to (select from Country where c_id = 1)
create edge comesFrom from (select from Immigrant where i_country = 2) to (select from Country where c_id = 2)
create edge comesFrom from (select from Immigrant where i_country = 3) to (select from Country where c_id = 3)
答案 0 :(得分:0)
您可以使用OrientDB ETL来执行此操作。有关更多信息,请查看此示例:http://orientdb.com/docs/last/Import-from-CSV-to-a-Graph.html