Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-29-2019 11:35 PM
While importing from CSV,, I have the following fields
empid,
empname,
gender
add1
add2
add3
city
state
country
month
year
salary
the employee records can be duplicated since they are paid salary every month.
the following labels needed to be created, EMPLOYEE, EMPLOYEE_ADDRESS, CITY, STATE, COUNTRY, SALARY
EMPLOYEE can be merged using empid. So whenever employee is created the address needed to be created. For Adddress field, add1 cannot be null, but add2, add3 can be null.
So how to create the ADDRESS node, only if the employee Node is created
06-30-2019 12:11 AM
Try this:
MERGE (e:Employee {empid: line.empid, empname: line.empname})
//case1: add2 and add3 are both NULL..................
FOREACH(ignoreMe IN CASE WHEN line.add2 IS NULL AND line.add3 IS NULL THEN [1] ELSE END |
MERGE (a:Address {add1: line.add1})
MERGE (e)-[EMPLOYEE_ADDRESS}->(a)
)
//case2: add2 and add3 are NOT NULL..................
FOREACH(ignoreMe IN CASE WHEN line.add2 IS NOT NULL AND line.add3 IS NOT NULL THEN [1] ELSE END |
MERGE (a:Address {add1: line.add1, add2: line.add2, add3: line.add3})
MERGE (e)-[EMPLOYEE_ADDRESS}->(a)
)
//case3: add2 IS NOT NULL and add3 IS NULL..................
FOREACH(ignoreMe IN CASE WHEN line.add2 IS NOT NULL AND line.add3 IS NULL THEN [1] ELSE END |
MERGE (a:Address {add1: line.add1, add2: line.add2})
MERGE (e)-[EMPLOYEE_ADDRESS}->(a)
)
//case4: add2 IS NULL and add3 IS NOT NULL..................
FOREACH(ignoreMe IN CASE WHEN line.add2 IS NULL AND line.add3 IS NOT NULL THEN [1] ELSE END |
MERGE (a:Address {add1: line.add1, add3: line.add3})
MERGE (e)-[EMPLOYEE_ADDRESS}->(a)
)
All the sessions of the conference are now available online