petrounias/django-cte-trees

Docs: explanation of "Pharaoh, Grandmother, and Monarchy deletion patterns"

Opened this issue · 3 comments

The docs mention:

Multiple delete semantics: supports Pharaoh, Grandmother, and Monarchy deletion patterns

and I wondered what this meant - I did some googling, and found nothing.

Is this your internal terminology? Some more explanation in the docs would be helpful.

@drkvogel See here: https://github.com/petrounias/django-cte-trees/blob/master/cte_tree/models.py#L113-L119

I don't know if django-cte-trees is still maintained though. I have continued the work a bit here https://github.com/matthiask/django-cte-forest but have stopped working on this in the meantime as well.

@matthiask Thanks, I have seen the code already, but it is not clear what these terms mean, and if they are well-known terminology or just names created by the developers (it would seem the latter). I will look at your fork.

Original author here: I encountered these terms in a book on Common Table Expressions over a decade ago, but I cannot remember nor find the book today - I will update if I do.

Pharaoh mode means all descendants are also deleted.

Grandmother mode means the parent of the deleted node becomes the new parent of all children of the deleted node (this requires multiple roots if a root node is the subject of deletion). The order of the children is preserved.

Monarchy mode means the first child of the deleted node becomes the new parent of the remaining (if any) children of the deleted node (its former siblings). What constitutes the first child depends on the ordering of the CTE as with all other operations.