Re: Table inheritance or LIKE table?

From: Bob Henkel <luckyratfoot(at)gmail(dot)com>
To: Steve - DND <postgres(at)digitalnothing(dot)com>
Cc: postgres-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Table inheritance or LIKE table?
Date: 2005-04-10 04:18:21
Message-ID: 762e5c0504092118628225fc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Apr 9, 2005 10:55 PM, Steve - DND <postgres(at)digitalnothing(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2005-04-10 04:22:54 Re: Checking cursor's state in plpgsql
Previous Message Steve - DND 2005-04-10 03:55:53 Table inheritance or LIKE table?