简体   繁体   English

如何在关系上建立关系模型?

[英]How to model relationships on relationships?

I've to solve next problem: 我要解决下一个问题:

I have 3 nodes: 我有3个节点:

(n:Node)-[r:HAS_ATTRIBUTE]->(a:Attr {name ="xxxx"}) ->(t:Type)

all the a:Attr nodes have :Translation associations: 所有a:Attr节点都具有:翻译关联:

(a) -> [:_HAS_TRANSLATION] -> (tr1:Translation {name : "yyyy", lang ="fr"})

(a) -> [:_HAS_TRANSLATION] -> (tr2:Translation {name : "kkkk", lang ="de"})

Now, I would like to use relationships to model the same things: 现在,我想使用关系来建模相同的事物:

(n:Node)-[r:HAS_ATTRIBUTE {name ="xxxx"}]->(t:Type)

How can I add translation to the HAS_ATTRIBUTE name property, of course without adding new _HAS_ATTRIBUTE to the n:Node ? 我如何在不将新的_HAS_ATTRIBUTE添加到n:Node情况下,将翻译添加到HAS_ATTRIBUTE name属性?

I should need to have such a thing as a RELATIONSHIP on the RELATIONSHIP ... 我应该在RELATIONSHIP上有一个RELATIONSHIP之类的东西...

Hopefully I'm understanding your question. 希望我能理解您的问题。

Consider an intermediate node, eg 考虑一个中间节点,例如

(n:Node)-[:HAS_ATTRIBUTE]->(attr:Attribute {name: "X")),
(attr)-[:HAS_TRANSLATION]->(tr1:Translation),
(attr)-[:HAS_TYPE]->(t:Type)

...or something of the like. ...或类似的东西。 Note that "attr" would be the new, intermediate node (you can name the relationships whatever you please, obviously). 请注意,“ attr”将是新的中间节点(显然,您可以随意命名关系)。

If you need to be more specific (eg instances of attributes), you can always replace "attr" with something like "specificAttr" and have "attr" point to "attr". 如果您需要更具体(例如属性实例),则可以始终将“ attr”替换为“ specificAttr”,并使“ attr”指向“ attr”。

Intermediate nodes are a great way of tackling modeling questions like this where you need to qualify a relationship more fully. 中间节点是解决此类建模问题的好方法,在这种情况下,您需要更充分地限定关系。

If I understand you correctly you want to have only 2 nodes and one relationship, right? 如果我对您的理解正确,那么您只希望有2个节点和1个关系,对吗?

To achieve this you can simply do 为此,您只需

(n:Node)-[r:HAS_ATTRIBUTE]->
(a:Attr {name ="xxxx", lang_fr="yyyy", lang_de="zzzz"})->
(t:Type)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM