cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

Is there any way to prevent nodes used for dependent entities to become totally disconnected?

cristiscu
Node Clone

@andrew.bowman has a great example when such a dependent entity (a report card node) should always be created with a relationship to its parent (a student node). But you can later delete its relationship, and leave a report unrelated to anyone.

Relational databases emulate dependent entities with PKs including the PK of their parent. And you can make sure, with CASCADE DELETE/UPDATE, no child will remain without its parent.

I'm only curious if there is anything in Neo4j to prevent deleting the last relationship to such a node emulating a dependent entity.

1 ACCEPTED SOLUTION

There's no native functionality for such constraints at the present time.

You may need to create your own triggers for such a thing, or do occasional sweep queries for child nodes lacking the expected relationship to the parent, then delete.

View solution in original post

2 REPLIES 2

There's no native functionality for such constraints at the present time.

You may need to create your own triggers for such a thing, or do occasional sweep queries for child nodes lacking the expected relationship to the parent, then delete.

But that's exactly what I was looking for!

Thanks,
-C

PS: I could have never imagine I'll find triggers implemented in APOC, through functions Looks great!

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online