问题描述
我正在学习Neo4j,目前正在白板上考虑我所想的场景.我有3个产品P1,P2,P3. P1和P2是独立产品. P3是可帮助您连接P1和P2的适配器.
I'm learning Neo4j and currently whiteboarding the scenario i'm thinking of.I have 3 products P1, P2, P3. P1 and P2 are standalone products. P3 is an adapter that helps you connect P1 and P2.
我想到了P1-[connects_to]-P2
,其中P3是connects_to
关系的属性,但是那我怎么存储P3的属性呢?如果我将所有三个产品都创建为节点并执行P1-[connects_to]-P3
和P2-[connects_to]-P3
,则这并不真正代表域.如何在Neo4j中对此建模?
I thought of P1-[connects_to]-P2
, with P3 as a property of the connects_to
relationship, but then how'd I store P3's properties?if i create all three products as nodes and do P1-[connects_to]-P3
and P2-[connects_to]-P3
, that's not really representative of the domain.How do i model this in Neo4j?
推荐答案
我认为您可以使用类似的模型:
I think you can use a similar model:
(P1)-[:connected_through]->(A:Adapter)<-[:connected_through]-(P2)
(A)-[:type_is]->(P3)
这篇关于如何通过neo4j中的第三个节点对两个相关的节点建模?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!