Reputation: 149
I understand that in a graph DB, relations are created after insertion and instead or field to field relations, they are record to record relation. If my understanding is correct, then what do I need to do when I import a million records from a CSV file and need to relate them to records in the other table?
Is it not possible to relations (edges) at design time, before insertion so that whenever a record is inserted, it has a relation already there?
My database is detailed as below.
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
If I create the edges manually, it will be like this.
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)
Upvotes: 0
Views: 78
Reputation: 9060
You can use OrientDB ETL to do that. For more information look at this example: http://orientdb.com/docs/last/Import-from-CSV-to-a-Graph.html
Upvotes: 0