Re: Table inheritance or LIKE table? - Mailing list pgsql-general

From Bob Henkel
Subject Re: Table inheritance or LIKE table?
Date
Msg-id 762e5c0504092118628225fc@mail.gmail.com
Whole thread Raw
In response to Table inheritance or LIKE table?  ("Steve - DND" <postgres@digitalnothing.com>)
List pgsql-general

On Apr 9, 2005 10:55 PM, Steve - DND <postgres@digitalnothing.com> wrote:
What is the general consensus on using table inheritance? I know it's there,
but is it good, bad, or just dependent on how it's used? I need to track
creation/update information for a large number of tables in my current DB. I
was just going to create a table with the template of fields I was looking
for, and use LIKE in the table definition. It turns out that LIKE does not
maintain FK constraints, or indexes.

Would this be a good situation to use inheritance? Since the data in
question is identical for all of the tables it will be used on, it seems
like it might be the right path. Are there any performance issues with table
inheritance?

Below is the DDL for the table in question.

CREATE TABLE create_update_info (
       created_by_user_id integer NOT NULL,
       created_on timestamp DEFAULT timezone('UTC', now()) NOT NULL,
       updated_by_user_id integer NOT NULL,
       updated_on timestamp DEFAULT timezone('UTC', now()) NOT NULL,
       FOREIGN KEY (created_by_user_id) REFERENCES users(user_id),
       FOREIGN KEY (updated_by_user_id) REFERENCES users(user_id)
)

Thanks,
Steve

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

This doesn't answer your question, but why use inheritance?   What advantage will it give you? And what if in the future you do need the FK constraints?  By using inheritance as it's currently implemented you will only be locking your self into a design. Just my 2 cents

pgsql-general by date:

Previous
From: "Steve - DND"
Date:
Subject: Table inheritance or LIKE table?
Next
From: Bruce Momjian
Date:
Subject: Re: Checking cursor's state in plpgsql