Hello, All! Is somebody have an experience using inheritance in PostgreSQL?
Is it worth to use it, or better to keep hands of :)? In which situation you would use it?
To be true I'm a little bit in doubt about mixing relational and OO models...
Hello, All! Is somebody have an experience using inheritance in PostgreSQL?
Is it worth to use it, or better to keep hands of :)? In which situation you would use it?
To be true I'm a little bit in doubt about mixing relational and OO models...
Its nice but be sure your understand the caveats outlined in the manual before using it. Currently the way it handles constraints is a bit rough but its on the todo list. It is particularly useful with partitioning. A more OO example would be inheriting from the people table to create an employees table.
Of course the downside is that its not portable to any other rdbms's so if you had to rehost a database on another rdbms you'd have to rewrite a bunch of stuff.
Probably not, there are caveats to PostgreSQL table inheritance, such as no globally unique constraints, so you lose many of the consistency guarantees. Also writing well-performing queries can be quite a challenge. As pointed out by Scott, PostgreSQL inheritance is only really useful for table partitioning where it's a performance tradeoff to begin with.
There are 2 common ways to use standard SQL idioms for class inheritance: