views:

57

answers:

1

Hello, 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

+3  A: 

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.

Diogo Biazus
Thanks for your answer.I decided to use inheritance at least for LASTUPDATE and I noticed the following and I do not know if it is correct. Instead of using the an ID field per table I am using the one of the parent table for all tables. This option seems to be OK.What is your opinion?**LastUpdate**Name TypeID SerialLastUpdateUser Varchar 10LastUpdateDate Date**Contacts** Name TypeDescription Varchar 30Value Varchar 30**LastUpdate Inherint**
ekekakos