DDL Queries
index
creating index
CREATEINDEX index_name FOR (n:Person) ON (n.surname)creating composite index:
CREATEINDEX index_name FOR (n:Person) ON (n.age, n.country)show all indices:
CALL db.indexesdeleting index
DROP INDEX index_name
unique constraint
create unique constraint on node.id
CREATE(dhawan:Player{id:001, name: “shikar Dhawan”, YOB: 1995, POB: “Delhi”})CREATE(jonathan:Player {id:002, name: “Jonathan Trott”, YOB: 1981, POB: “CapeTown”})CREATE(sangakkara:Player {id:003, name: “Kumar Sangakkara”, YOB: 1977, POB: “Matale”})CREATE(rohit:Player {id:004, name: “Rohit Sharma”, YOB: 1987, POB: “Nagpur”})CREATE(virat:Player {id:005, name: “Virat Kohli”, YOB: 1988, POB: “Delhi”})// create unique constraintCREATECONSTRAINT constraint_name ON (n:Player) ASSERT n.id ISUNIQUE// verify constraintCREATE(virat:Player {id:005, name: “Virat Kohli”, YOB: 1988, POB: “Delhi”})create node key constraint:
CREATE CONSTRAINT constraint_name ON (n:Person) ASSERT (n.firstname, n.surname) IS NODE KEYshow all constraints:
CALL db.constraintsdrop unique constraint:
DROPCONSTRAINT constraint_name
relationship constraints
CREATECONSTRAINT constraint_name ON ()-[like:LIKED]-() ASSERT exists(like.day)todo