Re:Listen to your to PostgreSQL database in realtime via Web...
by saurik on Friday April 30, 2021 @06:18PM
(#27000175)
I would consider this model "usually incorrect" in that it is quite likely you will eventually want to be able to move an entity to a different parent. I would thereby always give people the advice that one "should" have primary keys for every entity type that are at least global for that local entity type (if not truly global for all entity types, as there is a lot of power doing such) and then implement this child relationship as a unique foreign key constraint, unless you have some very specific functionality or performance requirement that would force primary key conflation (and FWIW, "I want to use this WAL watcher" might count, but it seems like a steep price to pay being unable to do sane reparenting).
[ Parent
| on HN ]
Re:Listen to your to PostgreSQL database in realtime via Web...
by skyde on Thursday May 06, 2021 @12:49AM
(#27059262)
I agree the children entity ID must be already unique without having to use the parent entity id.
It's just that in my experience have the children table primary b-tree sorted on ParentID then childrenID make join much more efficient unless you can use table interleaving like in Google SpannerDB https://cloud.google.com/spanner/docs/schema-and-data-model#...