Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-08-2020 12:07 PM
Good day. I've gone through the basic Neo4j and Cypher lessons. However, I have yet to start my first project -- until now. I'm a little rusty on what I studied in the spring. I have a list of employees who travel and work around the world. The employees might speak several languages and have several specialty areas they work in. Here is a sample of the data I want to enter as a graph:
Nodes
Associate
name: string
account#: string
Specialty
specialty: string (most associates will have multiple specialties)
Country
country: string
Organization
name: string
location: string
HealthCoverage (multiple types per associate possible)
type: string
Language
language:string
(I need to collect proficency level of each language spoken -- should this be a property of the language? Or a property of the SPEAKS relationship?)
Relationships
SPEAKS
SERVES_IN
SERVES_AT
HAS_SPECIALTY
HAS_HEALTH_COVERAGE
A simple query would find all associates with a certain specialty area, speaking French at a level 3 proficiency working in Peru.
Oh, and I'm trying to figure out the best way to set up my .csv file.
Do I list all of the Nodes as columns? Do I use a separate .csv for each node? How do I link them together?
Thanks!
John the Noob
12-08-2020 12:41 PM
Try this:
Assuming this .csv file structure:
Associate,Specialty,Country,Organization,HealthCoverage,Language,Proficiency
MERGE (a:Associate {name: "XYZ"})
MERGE (s:Specialty {specialty: ["XYZ","ABC"]})
MERGE (c:Country {country: "Peru"})
MERGE (o:Organization {name: "ABC"})
MERGE (h:HealthCoverage {name: "AMX"})
MERGE (l:Language {languages: ["English", "French"], profieciency: toInteger("3") })
MERGE (c)-[:ORGANIZATION]->(o)
MERGE (o)-[:ASSPOCIATE]->(a)
MERGE (a)-[:SPECIALTY]->(s)
MERGE (a)-[:HEALTH_COVERAGE]->(h)
MERGE (a)-[:LANGUAGES]->(l)
12-08-2020 02:52 PM
Thank you for your quick reply. That looks good. I appreciate your help and will give it a try a little later.
Have a great day!
John
12-09-2020 05:56 AM
John,
collect proficency level of each language spoken -- should this be a property of the language? Or a property of the SPEAKS relationship?
I recommend you move proficiency to the relationship.
Also consider having a master set of Specialty nodes (1 per specialty) and link the person to each node. You can do that even if your CSV file is has single column with comma separated values
see this post for some ideas about CSV structure and load cypher - Populating database from CSV file with relations
12-09-2020 02:58 PM
Robert,
Thank you for taking the time to respond. I appreciate your helpful insights. I'm looking at the article you recommended now.
Have a great day!
John
All the sessions of the conference are now available online