On Tue, Oct 17, 2023 at 5:36 PM Jeff Laing <Jeff.Laing@xxxxxxxxxxxxxxx> wrote:
“Don’t use table inheritance” IS on that page
Yeah, inheritance probably would have been removed a long time ago except that it was underneath the partitioning feature. The basic idea of implementing polymorphic record storage essentially hacks SQL in a way it doesn't want to be hacks, thus the feature never really worked properly. If you want variant storage, use hstore, json, etc. or use the various techniques that split the entity across multiple tables.
The only thing you can't really do in SQL easily without writing nasty triggers are things like, 'this table must be linked from one and only one of these candidate tables'. I think the language probably ought to support this, but I don't think postgres would unless the standard did. I try to avoid handwriting RI when possible in triggers, but in this case it's the only approach that works within language constraints and can formally validate the model.
merlin