cancel
Showing results for 
Search instead for 
Did you mean: 

Can we create composite primary key while exporting nodes to neo4j using Dataiku Neo4j plugin?

ans
Node

Suppose I have a table with below columns:

emp_id | emp_name | emp_department | date_of_joining


I want to create a composite primary key named "ID" as

ID = emp_id + "_" + date_of_joining

I prepared my data by concatenating two columns and creating ID field. Then using ID field as a primary key in export nodes recipe. Please refer the attachment.


Is there a more straight forward way to define which columns I need to use as a composite key and providing a name for it in recipe, rather than preparing the data manually?
Does neo4j handle this itself and provide an option like it does for defining primary key?

1 REPLY 1

ameyasoft
Graph Maven

Q:Is there a more straight forward way to define which columns I need to use as a composite key and providing a name for it in recipe, rather than preparing the data manually?

A:First import the data without any concatenating. Once the import is done you can write a Cypher query to concatenate ID and date_of_joing properties.  Either you can update the existing ID value with the concerted value or add a new property to store the concatenated value. This way you will have the flexibility of selecting properties to concatenate.

Here is an example:

//Created a new employee node...

MERGE (a:Employee {ID: "123", name: "John", department: "Sales", joiningDate: "01-01-2000"})
//Concatenating.........here I update ID value
match (a:Employee)
with (a.ID + "_" + a.joiningDate) as ID2, a
set a.ID = ID2
//create new property......
//set a.compositeID = ID2
return a
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.