Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BE6FF475B33 for ; Thu, 30 Jan 2003 01:27:08 -0500 (EST) Received: from web12703.mail.yahoo.com (web12703.mail.yahoo.com [216.136.173.240]) by postgresql.org (Postfix) with SMTP id 0D92E47595A for ; Thu, 30 Jan 2003 01:27:08 -0500 (EST) Message-ID: <20030130062707.48883.qmail@web12703.mail.yahoo.com> Received: from [203.107.130.9] by web12703.mail.yahoo.com via HTTP; Wed, 29 Jan 2003 22:27:07 PST Date: Wed, 29 Jan 2003 22:27:07 -0800 (PST) From: chester c young Subject: Re: Inheritence and Integrity To: Neal Lindsay Cc: pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/492 X-Sequence-Number: 11357 > inheriting pk and triggers pg inheritance is quite limited. what i (and i'm sure many others) have done is: 1. create master sequence 2. create base table 3. create base trigger procedures 4. create derived tables, using "inherit" 5. write procedure p( table_name ) that a) sets pk of table_name using master sequence b) attaches base trigger procedures onto table_name 6. run procedure p() against each derived table another way to skin this cat is to use "objects" in the database: -- base table table common( int id primary key ..., ref_tab name, -- name of secondary table using common ... -- common columns and constraints ) without oids; -- secondary table table secondary1( int id1 not null references common(id), int id2 primary key, -- (can use id1 as pk!) ... -- secondary columns and constraints ) without oids; -- views for secondary table - generate! create secondary1_v1 as select c.*, s.* from secondary1 s join common c on( s.id1 = c.id ); -- (if you want) dml for view to make life easier - generate! ... if you are maintaining the common info, or if you want a many to one secondary to master, this approach is easier. __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com