Cypher

constraint

A rule the database enforces on every node or relationship with a given label or type, rejecting any write that breaks it.

Also written: constraints

Example

Every (:Person) must hold a name.

cypher
CREATE CONSTRAINT Person_name_exists IF NOT EXISTS
FOR (p:Person) REQUIRE p.name IS NOT NULL

A write creating a (:Person) without a name is rejected, and so is one removing the name from a person already in the graph. Either way the transaction fails and nothing is stored.

Lessons that use this term

The lesson and course links below open in a new tab.

66 lessons use this term. The 40 with the highest term density are listed here.

Cypher Indexes and Constraints195 mentions

Importing CSV data into Neo4j24 mentions

  • Unique IDs and ConstraintsCreating Nodes, Properties, and Relationshipscan add constraints to your database to stop the creation of nodes with duplicate12 mentions
  • Congratulations and Next StepsImporting data considerationsCreate constraints on3 mentions
  • Building an Import ProcessImporting data considerationsCreate Person and Movie constraints Import data from persons.csv and create Person nodes Import data from movies.csv and create Movie nodes -5 mentions
  • Adding Movie NodesCreating Nodes, Properties, and Relationshipsa constraint to ensure that there are no duplicate4 mentions

Graph Type Schema Enforcement33 mentions

  • Constraints and Extending Graph TypesSchema Enforcement with Graph Typesthis lesson, you will add property constraints to enforce uniqueness and mandatory fields, then use the ADD command to build on an existing graph type without16 mentions
  • Extend the Graph TypeSchema Enforcement with Graph Typesthe previous lesson, you learned how graph types express property constraints, the difference between SET and ADD, and how to define relationship element1 mention
  • Managing Graph TypesSchema Enforcement with Graph Typesnow have a graph type with node types, relationship types, and constraints10 mentions
  • Complete Recommendations SchemaSchema Enforcement with Graph Typeshave learned how to define node types, relationship types, and constraints2 mentions

Using Neo4j with Go2 mentions

  • Error handlingBest practicesConnection errors - Network issues, authentication failures Constraint errors - Violations of database constraints Transaction errors - Deadlocks, timeout issues Query errors -2 mentions

Importing Data Fundamentals10 mentions

Importing Data into Neo4j Workshop7 mentions

  • Unique IDs and ConstraintsNeo4j Data Importerthis lesson, you will explore the importance of unique IDs, constraints and6 mentions

Using Neo4j with .NET3 mentions

  • Error handlingBest practices—Raised when the Cypher syntax is invalid or a constraint is violated AuthenticationException —Raised when authentication fails ServiceUnavailableException —Raised when3 mentions

Using Neo4j with Python4 mentions

  • Handling Database ErrorsBest practicesRaised when the Cypher syntax is invalid ConstraintError - Raised when a constraint unique or other is violated AuthError - Raised when authentication fails TransientError - Raised when the3 mentions
  • Handling errorsBest practiceswith the same email address, and instead relies on the database to enforce the constraint1 mention

Using Neo4j with Java3 mentions

  • Handling errorsBest practiceswith the same email address, and instead relies on the database to enforce the constraint1 mention
  • Handling Database ErrorsBest practicescommon scenario is dealing with constraint violations when inserting2 mentions

Building Neo4j Applications with Spring Data4 mentions

LOAD CSV Data Import17 mentions

Neo4j Management, Optimization, and Refactoring Workshop10 mentions

GraphRAG Hackathon3 mentions

  • Querying with CypherIntroduction to GraphRAGUse MATCH, WHERE, and MERGE to query and write data Create indexes and constraints to keep your graph performant Traverse multi-hop paths — the foundation of GraphRAG3 mentions

Graph Data Modeling Fundamentals2 mentions

Context Graphs: Agent Memory with Neo4j1 mention

  • Store your first memoryIntroduction to Agent Memorytakes a few seconds longer than later ones, because the library creates its constraints and vector indexes before writing1 mention

All glossary terms