在neo4j v.2(密码)中建模条件关系 [英] Modeling conditional relationships in neo4j v.2 (cypher)

查看:91
本文介绍了在neo4j v.2(密码)中建模条件关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个需要帮助的相关问题.

I have two related problems I need help with.

问题1:如何为条件关系建模? 我希望我的数据表明,当测试CLT1的"Result"属性="High"时,CLT1与疾病A相关.如果我采用以节点为中心的方法,那么我想代码可能类似于...

Problem 1: How do I model a conditional relationship? I want my data to indicate that when test CLT1's "Result" property = "High", CLT1 has relationship to Disease A. If I take a node-centric approach, I imagine that the code might look something like...

(CLT 1 {Result: "High"})  -[:INDICATES] -> (Disease A)

此外,当CLT1的结果"属性=低"时,CLT1与疾病B有关系

Further, when CLT1's "Result" property = "Low", CLT1 has a relationship to Disease B

(CLT 1 {Result: "Low"})  -[:INDICATES] ->  (Disease B)

或者,如果我采用以关系为中心的方法,则代码可能看起来像这样……

Alternatively, if I take a relationship-centric approach, the code might look like this...

(CLT 1) -[:INDICATES {Result: "High"}] -> (Disease A)
(CLT 1) -[:INDICATES {Result: "Low"} ] -> (Disease B)

问题2

我有过对数据建模的经验,有1个节点具有唯一的名称,但是具有不同的标签或属性.问题是我希望这些节点是可区分的.但是,它们与cypher看起来并不一样.

I have had the experience that I am modeling my data, there is 1 node with a unique name, but either different labels or properties. The thing is that I want these nodes to be distinguishable. However, they are not as they look the same to cypher.

我可以给他们提供多个属性,标签或不同的名称.标签或属性(1 + n标签,属性)或不同名称中的每个不同类都必须具有多样性.

I can either give them multiple properties, labels or different names. The diversity has to be for each different class... in labels or properties (1+n labels, properties) or in different names.

问题2与问题1有关,因为我无法建立条件关系的模型,也无法通过其标签或属性来区分同一节点(CLT1).我可能必须通过在关系中设置可查询的条件"来解决它.

Problem 2 relates to Problem 1 in that I can't model the conditional relationship or distinguish the same node (CLT1) by its labels or properties. I may have to resolve it by making the query-able "condition" in the relationship.

我有这个权利吗?我还有其他选择吗?

DO I have this right? Do I have any other options?

推荐答案

对于您的第一个问题,我将采用以关系为中心的方法,因为这种方法代表了从结果节点到疾病的信息推断.

For your first question, I'd take the relationship-centric approach as this kind of represents the inference of the information leading from your result-node to the disease.

在建模和查询中也应能很好地工作.

Should work pretty well in modeling and querying too.

第二个问题.这就是节点标签的含义,它们代表节点可以播放的不同角色,每个角色具有不同的相关属性和关系.

For your second question. That's what node-labels are for they represent different roles a node can play, each with different relevant properties and relationships.

因此您可以执行MATCH (p:Person {name:"Jose"})并将其与MATCH (d:Developer {name:"Jose"})区别对待.也就是说,看看其他道具和缺点.

So you could do MATCH (p:Person {name:"Jose"}) and treat it differently from MATCH (d:Developer {name:"Jose"}). I.e look at other props and rels.

这篇关于在neo4j v.2(密码)中建模条件关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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