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

@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.

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! :slight_smile:

Thanks,
-C

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