How does inheritance work in Postgresql?

Asked

Viewed 568 times

9

How does inheritance work in Postgresql? Is it a good practice in relational databases? How to use it?

1 answer

9


It doesn’t work. In practice it is implemented in half and is very rare to be useful for something, although the functional part is not especially problematic.

In general, it is not "good practice" to try to reproduce the object-oriented model in a relational database. It’s more work doing it right than doing it the old-fashioned way. Maybe it would be different if everything was done perfectly, but they abandoned it because it wasn’t really something so useful and it would never be as good as people expect.

So I’m not even going to try to explain how it works, no one in their right mind uses it, at least as a legacy of truth. There is use for partitioning, but it is to use the inheritance mechanism not to make inheritance, but to supply another need.

When you have several tables with the same structure that need to be grouped in some way inheritance can be used, but note that this is not actual inheritance as we know it in object orientation.

  • 2

    +1 for "no one is using" and for sincerity.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.