Neo4j创建约束

本文概述

在Neo4j中, 约束用于对可以针对节点或关系输入的数据施加约束。

Neo4j有两种类型的约束:

唯一性约束:它指定属性必须包含唯一值。 (例如:没有两个带有玩家标签的节点可以共享”目标”属性的值。)

属性存在约束:它确保具有特定标签的所有节点或具有特定类型的所有关系都存在一个属性。


创建唯一性约束

CREATE CONSTRAINT ON语句用于在Neo4j中创建唯一性约束。

CREATE CONSTRAINT ON (Kalam:president) ASSERT Kalam.Name IS UNIQUE

输出

Neo4j创建约束1

验证

使用:schema命令检查约束。

:schema
Neo4j创建约束2

财产存在约束

属性存在约束用于确保具有特定标签的所有节点都具有特定属性。

注意:存在属性约束仅在Neo4j Enterprise Edition中可用。

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_47537.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?