Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-30-2019 10:38 AM
Following scenario:
Peter | Bob
Bob | Karl
Peter | Karl
Karl |
...
ABC | Bob
CDE | Bob
XZY | Karl
...
What I'd like to create Relationships between all(!) persons and teams.
match(p:Person),(t:Team) where p.person= t.boss create (p)-[:IS_BOSS]->(t)
Peter | Bob
Bob | Karl -[IS_BOSS]->ABC,CDE
Peter | Karl
Karl | -[IS_BOSS]->XZY
...
match(p:Person),(t:Team) where p.boss= t.boss create (p)-[:MEMBER]->(t)
Peter | Bob -[IS_MEMBER]->ABC,CDE
Bob | Karl -[IS_BOSS]->ABC,CDE
Peter | Karl -[IS_MEMBER]->ABC,CDE
Karl | -[IS_BOSS]->XZY
Any ideas?
10-30-2019 11:45 AM
It's a little tough to read those tables of results, as I can't tell what Cypher is being used to produce them.
One note first on this:
(:Person)-[:IS_BOSS]->(:Team)
You might consider :BOSS_OF instead, or otherwise reversing the direction, because currently :IS_BOSS points to :Team, which doesn't sound right, the team isn't the boss.
Likewise maybe :MEMBER_OF would work better since it points at :Team, since right now :MEMBER points to :Team, which may be confusing as team isn't a member.
As for connecting people, this should work (using the suggested :BOSS_OF and :MEMBER_OF for clarity):
MATCH (p)-[:MEMBER_OF]->()<-[:BOSS_OF]-(boss:Person)
MERGE (p)<-[:BOSS_OF]-(boss)
At that point you should be able to remove the boss property from all nodes.
All the sessions of the conference are now available online