Adding more nodes and edges to existing database and creating relationships with existing nodes/edges #3594
-
Hi, I have a few questions:
Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @kamalikaray, yes those are possible. I'll try to address each of your questions below: 1. Add nodes/edges to an existing databaseThis can be done in one of two ways. The first is for bulk import cases, where you want to add a large amount of data at once. // Create node table
CREATE NODE TABLE Person(name STRING, age INT64, PRIMARY KEY (name));
// Run COPY FROM with a subquery
COPY Person FROM (LOAD FROM "person1.csv" RETURN *);
COPY Person FROM (LOAD FROM "person2.csv" RETURN *); This allows you to individually import from different source files, assuming they conform to the schema. It also requires some prior work upfront to ensure that you do not have primary key conflicts in either file, so this approach makes sense when you have more faith in your upstream source of data that it provides data that's not duplicated in terms of primary key identifiers. If you cannot ensure that the data doesn't have duplicates, you could resort to the 2. Creating relationships with existing nodes in the old dbThis is simple: you first match on the existing nodes between which you want to create the edge, and then use a merge clause that overwrites the properties of an existing edge (or simply creates a new edge if it doesn't exist). See the docs for more on this. 3. Changing or adding more schemaYes, it's possible to update the schema once a table exists using the Feel free to mark this as the answer if it addresses your questions :) |
Beta Was this translation helpful? Give feedback.
Hi @kamalikaray, yes those are possible. I'll try to address each of your questions below:
1. Add nodes/edges to an existing database
This can be done in one of two ways. The first is for bulk import cases, where you want to add a large amount of data at once.
This allows you to individually import from different source files, assuming they conform to the schema. It also requires some prior work upfront to ensure that you do not have primary key conflicts in eith…