Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-08-2019 12:21 AM
I need to model 'Friend' relationship in neo4j. Relationship may have types like 'Buddy' or 'Friend'. For example, A and B are friends. A considers B as a 'Buddy' and B considers A as a 'Friend'. I see two options to model this.
Please let me know which one is good in terms of traversing complexity/performance. Thank you.
12-08-2019 01:36 PM
I'd suggest you create two edges:
CREATE (A)-[:BUDDY]->(B)
CREATE (B)-[:FRIEND]->(A)
Note that BUDDY
and FRIEND
are not properties here, they are relationship types.
12-09-2019 12:51 AM
If we create two relationship types, is it still possible to traverse people regardless of the type of the relation? For example, to retrieve all people who know person A.
12-09-2019 02:10 AM
MATCH (n)-[:BUDDY|FRIEND]->(A) RETURN n;
It's much faster this way as well since you can't index relationship properties.
12-17-2019 02:19 AM
Thank you very much for the help
All the sessions of the conference are now available online