我可以在关系之间建立关系吗? [英] Neo4j can I make relations between relations?

查看:78
本文介绍了我可以在关系之间建立关系吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用图形数据库(Neo4j),并且需要建立关系之间的关系,例如:

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

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

我想允许其他用户喜欢此活动(该user1跟在user2之后),对此的最佳实现是什么?

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

推荐答案

简短答案:

您无法创建与关系的关系.

Short answer:

You can't create a relation to a relation.

您必须在关系中间创建一个活动节点:

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

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

然后,您将可以通过在用户和活动节点之间创建关系来使另一个用户LIKE进行此活动.

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.

这篇关于我可以在关系之间建立关系吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆