ekekakos
ekekakos

Reputation: 63

Design a database with or without inheritance

I am trying to understand inheritance and how to use it with PostgreSQL. For this reason i design a database in the excel file. In the 1st columns you can see the table w/o inheritance while in the 2nd part of the sheet you can see the tables with INHERITANCE.

Can you give me your opinion and help on the following? 1. Which is the best design ( w or w/o inheritance )? 2. Is my design with inheritance good or sth is missing?

I am looking forward for your answer.

Thanks in advance

Elias

PS. Because I cannot upload the file please go to the folloing link

Upvotes: 1

Views: 502

Answers (1)

Diogo Biazus
Diogo Biazus

Reputation: 622

Inheritance in PostgreSQL is useful for partitioning data, but other than that I don't believe it has a good use. If you need a database design with generalization/specialization you can still do it using traditional database modelling techniques.
The traditional generalization/specialization is equally easy to read and maintain but it's far more portable and also easier to support in existent ORM layers.
If you decide to use database inheritance be sure to read the caveats section in the PostgreSQL manual. Otherwise you can run into some trouble with data constraints.

Upvotes: 3

Related Questions