Is `parent` field really needed?
amaury1093 opened this issue · 2 comments
amaury1093 commented
django-ltree-demo/demo/categories/models.py
Lines 7 to 8 in 5752252
Am i correct in saying that this field is not actually needed, since with a materialized path you already have the whole path to the root? It's just convenience field for to get each node's parent/children?
k4nar commented
With this demo you don't construct the path "by hand" but let PostgreSQL construct it for you, only based on who the parent is. So you actually need to store the parent's ID in order to let the DB do its stuff :) .
If you don't mind managing the path by yourself then, indeed, you don't need to store the parent. You also don't need the SQL triggers.
amaury1093 commented
Got it, thanks!