简体   繁体   English

neo4j中的复合关系

[英]Compound relationship in neo4j

I'm playing around with neo4j - seeing what I can and can't do with it before suggesting it for something serious. 我正在与neo4j玩耍-在建议将其用于一些严肃的事情之前,先看看我能做什么和不能做什么。 One thing that I'm trying to work out is if you can have what I'm calling a compound relationship. 我要解决的一件事是,如果您可以拥有我所说的复合关系。

In my playing, I'm doing a family tree - it seems an ideal fit. 在玩游戏时,我正在做一棵家谱-看起来很合适。 I'm wanting to express that a life event occurred between two people - getting married for example - and where it happened. 我想表达一个人生事件发生在两个人之间-例如结婚-发生了什么。 The MARRIED_TO relationship between two PERSON nodes is easy. 两个PERSON节点之间的MARRIED_TO关系很容易。 I'm struggling with the relationship to the PLACE node though. 我正在努力与PLACE节点建立关系。

In my head, it seems that what I really want is a relationship that goes from the PLACE node to the MARRIED_TO relationship, and I don't think that's possible. 在我的脑海中,似乎真正需要的是从PLACE节点到MARRIED_TO关系的关系,但我认为这是不可能的。

Alternatively, I could see the MARRIED_TO relationship going between three nodes, but that not only doesn't feel right but also isn't possible. 或者,我可以看到MARRIED_TO关系在三个节点之间进行,但这不仅感觉不正确,而且是不可能的。

The best i can see to do is either have a EVENT node representing the marriage, which feels clunky, or else have relationships from both PERSON nodes to the PLACE, which is then duplication of data. 我所能看到的最好的结果是要么拥有一个代表婚姻的EVENT节点(感觉很笨拙),要么拥有两个PERSON节点到PLACE的关系,然后再复制数据。

Is there a proper way of managing this kind of data? 是否有管理此类数据的适当方法? Or am I just missing something? 还是我只是想念一些东西?

Consider "Marriage" being a vital part of your domain. 将“婚姻”视为您网域的重要组成部分。 Anything being an entity deserves a separate node - so "Marriage" (or Event) becomes a node. 作为实体的任何事物都应有一个单独的节点-因此“婚姻”(或事件)成为一个节点。 That node then can be connected to the two people and the location. 然后,该节点可以连接到两个人和该位置。

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

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