On the subject of inheritance

From: Martin Foster <martin(at)ethereal-realms(dot)org>
To: PostgreSQL Novice List <pgsql-novice(at)postgresql(dot)org>
Subject: On the subject of inheritance
Date: 2006-04-14 21:49:33
Message-ID: 444018ED.5030403@ethereal-realms.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have been looking at documentation on inheritance and am not overly
clear on all aspects of it. Fortunately, the examples in 'PostgreSQL'
from 'Developers Library' showed examples which were helpful however I
am still curious if it would work for my circumstance.

I have a table which is used throughout the site and tracks users.
This information is what is required by the scripts to establish
identity, authenticate and correspond with off site. e.g.

USER
UserName VARCHAR(10)
UserPass VARCHAR(12)
UserEmail VARCHAR(30)

There is a new aspect to the site which is completely optional and seems
like a good candidate for inheritance of the user table. Simply put,
these additional attributes ADDITIONAL would be in a separate table
applied to and used only when necessary. This brings me to my questions.

OPTIONAL (Inherits from USER)
OptionalFirstName VARCHAR(15)
OptionalLastName VARCHAR(15)
OptionalAddress VARCHAR(45)
OptionalPhone VARCHAR(15)

First of all, does a row created in the USER table appear in the
OPTIONAL table which inherits from it? Meaning could I add in the
optional attributes at a later time using a simply ALTER TABLE OPTIONAL
statement when the UserName exists in USER?

Secondly, if the above is not possible does this require me to recreate
the entry from USER into OPTIONAL? And if so, what exactly happens?
Are there two records now or just one? Would I get a referential
integrity error and what would happened if the entry in USER was removed
would it be ripped from OPTIONAL as well?

Any clarification on this would be appreciated!

Martin Foster
martin(at)ethereal-realms(dot)org

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2006-04-14 22:48:39 Re: On the subject of inheritance
Previous Message Ennio-Sr 2006-04-14 21:27:38 Re: Colors/bold chars in a select?