如何建立条件关系?

编程入门 行业动态 更新时间:2024-10-24 14:26:09
本文介绍了如何建立条件关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个由组织运行的系统来实现某个功能,因此我有以下关系:

I have a system that is run by an organization to implement a certain function, thus I have the relationship:

组织→职能→系统

但有时功能仍然未知,在这种情况下,我想将系统直接绑定到组织:

but sometimes the function remains unknown, in which case I want to bind the system directly to the organization:

组织→系统

这种东西怎么写?

系统包含用于创建这些关系的属性,例如

the System contains attributes that are used for creating these relationships e.g.

create (s:System {id: 'x', Organization: 'MST', Function: 'CM'})

create (s:System {id: 'x', Organization: 'MST'})

这意味着我可以找到这样的节点:

which means I can find the nodes like this:

match (s:System), (o:Organization {Code: s.Organization}) optional match (f:Function {Code: s.Function})

...但是我如何建立关系?

...but how do I create the relationship?

推荐答案

我找到了 Mark Needham 的帖子:

I found Mark Needham's post:

www.markhneedham/blog/2014/06/17/neo4j-load-csv-handling-conditionals/

...它提供了一种折磨人的语法,但提供了一个解决方案.有没有更好的方法来实现这一点?

...which offers a torturous syntax but provides a solution. Is there a nicer way to accomplish this?

match (s:System), (o:Organization {Code: s.Organization}) optional match (d:Function {Code: s.Function}) foreach (n in (case when s.Function is null then [1] else [] end) | create (o)-[:Runs]->(s) ) foreach (n in (case when s.Function is not null then [1] else [] end) | create (o)-[:Function]->(f)-[:SupportedBy]->(s) );

更多推荐

如何建立条件关系?

本文发布于:2023-10-30 23:53:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544379.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条件   关系

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!