Re: REFERENCES constraint
| От | Peter Eisentraut |
|---|---|
| Тема | Re: REFERENCES constraint |
| Дата | |
| Msg-id | Pine.LNX.4.30.0108122136370.714-100000@peter.localdomain обсуждение исходный текст |
| Ответ на | Re: REFERENCES constraint (Cedar Cox <cedarc@visionforisrael.com>) |
| Список | 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')),
weightfloat4, ... 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@gmx.net http://funkturm.homeip.net/~peter
В списке pgsql-sql по дате отправления: