Neo4j can I make relations between relations?

2019-05-26 10:01发布

问题:

I'am using graph database (Neo4j) , and I need to make relations between relations , for example :

(user1)-[:FOLLOWED]->(user2)

I want to allow other users to like this activity (that user1 followed user2) , what's the best implementation for this ?

回答1:

Short answer:

You can't create a relation to a relation.

How to do?

You have to create an activity node in the middle of your relation:

(user1)-[:FOLLOWED]->(activity{date:..., blabla:...})-[:ACTIVITY_FOR]->(user2)

Then you'll be able to make another user LIKE this activity by creating a relation from user to activity node.

Relation names are subjectives, of course you can set your own relation names.