Cypher语言是在学习Neo4j时用到数据库操作语言(DML),涵盖对图数据的增删改查
neo4j数据库简单除暴理解的概念:
Neo4j中不存在表的概念,只有两类:节点(Node)和关联(Relation),可以简单理解为图里面的点和边。
在数据查询中,节点一般用小括号(),关联用中括号[]。
当然也隐含路径的概念,是用节点和关联表示的,如:(a)-[r]->(b),表示一条从节点a经关联r到节点b的路径。
1、Match
查找全部节点和关系(2种查询)
match(n)-->(m) return n,m
match(n) return n
查找Node
match(a:person) where a.name='Keanu Reeves' return a
查找特定节点,及关联节点(2种查询)
match(a:person)-[r:ACTED_IN]-(b:movie) where a.name='Keanu Reeves' return a,b,r
match(n:person{name:'Keanu Reeves'})-->(m) return n,m
2、Where
match(a:person) where a.name<>'Keanu Reeves' return a
match(a:person)-[r:ACTED_IN]-(b:movie) where a.name<>'Keanu Reeves' return a,b,r