3 ms·
> So any time you want to get all the CHILDREN of a PARENT you have to query all children to see if they have a FK to the appropriate PARENT. It's just an inde
by topmonk 7y ago
> So any time you want to get all the CHILDREN of a PARENT you have to query all children to see if they have a FK to the appropriate PARENT.
It's just an index lookup, so what? You'd rather mash all the data into a single parent field, is that it?
- dekhn 7y agoi will admit that once I saw postgres has arrays and composite types, it seemed more natural to model this as NODE with array of CHILDREN. I think it's more about the expressivity of pointers and arrays compared to the "backwardness-feeling" of index lookups.
- topmonk 7y agoSo now you have just created a many-to-many relationship. Due to a bug in software, a child could now be linked to multiple parents, or even no parents. Part of good database design is preventing corruption of these sorts of relationships. > I think it's more about the expressivity of pointers and arrays compared to the "backwardness-feeling" of index lookups. Greater expressivity in ways to store bad data is never a good thing.
- papln 7y agoHuh? If you have a tree with parent pointing to children, how do you get a child's parent? You need an index. Same as with a DB.