Re: REFERENCES constraint

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Cedar Cox <cedarc(at)visionforisrael(dot)com>
Cc: Jan Wieck <JanWieck(at)Yahoo(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: REFERENCES constraint
Date: 2001-08-12 19:42:47
Message-ID: Pine.LNX.4.30.0108122136370.714-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Cedar Cox writes:

> CREATE TABLE obj_weights (
> object_id int4 REFERENCES ( apple_objects(id) OR banana_objects(id) )
> weight float4,
> )

The way I would work this out is like this:

CREATE TABLE fruit_objects (
object_id serial PRIMARY KEY,
fruit_type text CHECK (fruit_type IN ('apple', 'banana')),
weight float4,
... other common fruit properties ...
);

CREATE TABLE apple_objects (
object_id integer REFERENCES fruit_objects,
color text,
... more apple properties ...
);

CREATE TABLE banana_objects (
object_id integer REFERENCES fruit_objects,
curvature real,
... other banana properties ...
);

--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2001-08-13 02:06:20 Re: REFERENCES constraint
Previous Message Cedar Cox 2001-08-12 19:01:13 Re: REFERENCES constraint