18.5. Delete semantics

When deleting a node or a relationship all properties for that entity will be automatically removed but the relationships of a node will not be removed.


Neo4j enforces a constraint (upon commit) that all relationships must have a valid start node and end node. In effect this means that trying to delete a node that still has relationships attached to it will throw an exception upon commit. It is however possible to choose in which order to delete the node and the attached relationships as long as no relationships exist when the transaction is committed.

The delete semantics can be summarized in the following bullets:

  • All properties of a node or relationship will be removed when it is deleted.
  • A deleted node can not have any attached relationships when the transaction commits.
  • It is possible to acquire a reference to a deleted relationship or node that has not yet been committed.
  • Any write operation on a node or relationship after it has been deleted (but not yet committed) will throw an exception
  • After commit trying to acquire a new or work with an old reference to a deleted node or relationship will throw an exception.