我可以在唯一性约束中指定多个标签吗? [英] Can I specify multiple labels in a uniqueness contraint?

查看:115
本文介绍了我可以在唯一性约束中指定多个标签吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将尝试使用两个标签在图表中的对象上创建唯一性约束,并且我想知道我是否可以期望它能够正常工作。

I am going to experiment with creating a uniqueness constraint on objects in my graph with two labels and am wondering if I can expect it to work.

我想要做这样的事情...

I want to do something like this...

CREATE CONSTRAINT ON (n:Object:Sub_graph_A) ASSERT n.name is unique;

CREATE CONSTRAINT ON (n:Object:Sub_graph_B) ASSERT n.name is unique;

同一个对象可以在整个图表中以相同名称存在,但在特定子图标中必须是唯一的-图形。

The same object can exist with the same name in the overall graph but must be unique in a particular sub-graph.

关于这是否是个好主意的任何想法?我应该知道我的技术成功是否足够快。我只是不确定这种方法是否合理(即我是否在Neo4j的设计能力范围内运行)。

Any thoughts on whether this is a good idea or not? I should know whether I am technically successful soon enough. I am just not sure if the approach is sound (i.e. am I operating within the design capabilities of Neo4j).

推荐答案

不幸的是目前只有一个标签和一个属性,我们计划稍后进行扩展。

No unfortunately currently there is only one label and one property, we plan to extend that later.

如果您希望它对两个标签都是唯一的,您可以创建两个约束每个标签。但那不是解决你的用例。我将从您的约束中删除:Object ,而是在上添加索引:对象(名称)

If you want it to be unique for both labels, you might create two constraints one for each label. But that's not addressing your use-case. I'd remove :Object from your constraint and instead add an index on :Object(name)

这篇关于我可以在唯一性约束中指定多个标签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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