Neo4j 上 RelationshipEntity 和关系之间的区别

difference between RelationshipEntity and relationship on Neo4j

在neo4j中关联2个节点你可以建立一个简单的关系或者建立一个RelationshipEntity,如图:relationship-entity

使用简单的关系,您可以添加 ... CREATE (Hugo)-[:ACTED_IN {roles:['Agent Smith']}]->(TheMatrix) ...

等属性

我的问题是:什么时候使用 RelationshipEntity 合适?它会在关系数据库的关系 n:m 中吗?

为什么在 relationship-entity 中使用关系实体而不是简单的关系?

来自文档Relationship-entity

To access the full data model of graph relationships, POJOs can also be annotated with @RelationshipEntity, making them relationship entities. Just as node entities represent nodes in the graph, relationship entities represent relationships. Such POJOs allow you to access and manage properties on the underlying relationships in the graph.

它的使用取决于您需要实现的目标。如果需要,您可以使用它来添加有关关系的更多详细信息。可能会在购买命令中添加价格。

CREATE (c:Customer {name:'User Test'})-[b:BUY {quantity:12}]->(i:Item {name:'Orange', price:15.0}) RETURN c,i

就我而言,我只在密码学习阶段使用过它