Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id ADFA49FBFE3 for ; Thu, 8 Mar 2007 16:25:10 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 13407-01 for ; Thu, 8 Mar 2007 16:25:08 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from web54303.mail.yahoo.com (web54303.mail.yahoo.com [206.190.49.113]) by postgresql.org (Postfix) with SMTP id 016CE9FBF5D for ; Thu, 8 Mar 2007 16:25:08 -0400 (AST) Received: (qmail 35841 invoked by uid 60001); 8 Mar 2007 20:25:07 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=MApcvpkjUQIg4MnDCebA3m9NMfUSQuboopDXhVpRJuV1ER8AT8gn8f9HHELSTAwp/LivZAGcEd8eb9EnUoXNeZ0wRbczasQfNNeDwE1/9lVR1/qS7TikPfcT27umNajb8QxorFh9jm3eKHoWJpfMYwLKjLXpeC+MRhnwvQh2SFE=; X-YMail-OSG: z8k6BSEVM1nGB2cPvz683noEnvI4ysYBc0gBqzfcX56zJ.B6G_1Tvg_RLXhRktWQpOfNuObbwN2hYL9FX1K6mLd9ZnFhq.wLmk1DzoFl.0oXioE9qvkV3jPHBb5Lf5JXGcI_DI1K43FuDHp0J97GT1I7ig-- Received: from [24.10.123.39] by web54303.mail.yahoo.com via HTTP; Thu, 08 Mar 2007 12:25:07 PST Date: Thu, 8 Mar 2007 12:25:07 -0800 (PST) From: chester c young Subject: Re: inheritance To: sql pgsql MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <437880.34674.qm@web54303.mail.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/85 X-Sequence-Number: 27723 > --- Greg Toombs wrote: > > > I'm trying to figure out how to nicely implement a C++ class-likesystem > > with PostgreSQL. Consider the following: > > Tables Fruit, Apple, Orange you can do this traditionally or through pg inheritance, although I do not think inheritance is well supported before 8.2. from years of experience the easiest approach and aesthetically the least satisfying approach is to put everything into the fruit table create table fruit( fruit_id integer primary key, fruit_tp varchar(12), ... ); with this approach you simply deal with whatever column's your interested in - with apples the orange specific columns are dead wood - they don't get in the way and take up no storage - you just need to learn to ignore them, maybe using views to help. you can have a fruit table plus apple and orange tables. create table fruit( fruit_id integer primary key, ) create table apple( apple_id integer primary key, fruit_id integer not null references fruit, ) you then need to build views to join fruit with apple and oranges, because some of the apple attributes are in the fruit table. lastly you need to handle dml. for example, when you insert an apple you need to insert into the fruit and the apple table. this can be done either through your application bracketing your dml with a begin and commit, or can be done through rules (much, much cooler) (the doc on rules will hold your hand through this). ____________________________________________________________________________________ Finding fabulous fares is fun. Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains. http://farechase.yahoo.com/promo-generic-14795097