Preventing Multiple Inheritance

From: Peter Fein <pfein(at)pobox(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Preventing Multiple Inheritance
Date: 2005-06-03 19:09:32
Message-ID: 42A0AAEC.60803@pobox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi-

Let's say I have a base table B (with a PK id, say) and two derived
tables D1 & D2 (with different cols). For a given B.id, I'd like to
allow only a corresponding row in *either* D1 or D2, but not both. Any
suggestions on how to do this? Should I not be using inheritance at all?

My thought was to add a column inherits_to to B with a value indicating
whether that row is really a D1 or a D2 and enforce it with appropriate
CHECK constraints on each of the derived tables.

Sorry if this is unclear...

--
Peter Fein pfein(at)pobox(dot)com 773-575-0694

Basically, if you're not a utopianist, you're a schmuck. -J. Feldman

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2005-06-03 19:19:23 Re: Determining when a row was inserted
Previous Message Gevik babakhani 2005-06-03 19:05:21 postgresql books