本质上,我有一个具有以下主键(表示简洁的PK)的表:parent_id integerchild_id和parent_id“子”表本身也包含“父”表的外键,并且lo,每个child_id总是引用上面表所期望的相同的parent_id。事实上,有一些额外的代码使两者保持同步。我分解为以下几个方面:child_id integer
date date
家长表: 1 | Parent A儿童桌: 1 | 1 | ChildSelect parent.child_id, parent.parent_id, parent.child_name from Child c Select NULL as child_id, parent.id as parent_id, parent_name as child_name
from
但也可以是这样的(没有第二个):| | 我的SQL查询如下所示:(select parent_id, child_id, 1 as h_level, array[parent_id,child_id] as fullpath
from public.entity_relations where parent_type