我有一个由组织运行的系统来实现某个功能,因此我有以下关系:
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) );更多推荐
如何建立条件关系?
发布评论