Inheritance and referential integritry in 7.0.3

From: "Alastair D'Silva" <deece(at)newmillennium(dot)net(dot)au>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Inheritance and referential integritry in 7.0.3
Date: 2001-04-08 05:04:16
Message-ID: 015201c0bfe9$5c667e80$0a02a8c0@riker
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am using PostgreSQL 7.0.3 and have the following schema:

CREATE TABLE "products" (
"id" SERIAL NOT NULL PRIMARY KEY,
"name" text NOT NULL,
"description" text NOT NULL,
"brand" text NOT NULL,
"url" text,
"weight" float4 NOT NULL,
"stock" int4 NOT NULL DEFAULT 0,
"price" decimal(10,2) NOT NULL DEFAULT 0,
"warranty" int4 NOT NULL
);

There are various other tables inheriting from "products".

CREATE TABLE "products1" INHERITS products (
"attribute1" text,
"attribute2" text
);

There is also another table which references products:

CREATE TABLE "properties" (
"product" int4 NOT NULL REFERENCES products (id) ON DELETE CASCADE,
"property" text NOT NULL
);

Now, if I insert a row into one of "products" child tables (eg, products1),
then try to reference it in "properties", it does not work as the product id
is only visible if products* is the target table. Changing the REFERENCES
target to product* products a syntax error, and creating a view as the
REFERENCES target is not allowed.

Short of creating another table which stores all product ids, is there a
simple way to make this work?

Cheers,

--
Alastair D'Silva (mob: 0413 485 733)
Networking Consultant
New Millennium Networking (web: http://www.newmillennium.net.au)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Glenn 2001-04-08 05:11:36 How to cache database?
Previous Message Bruce Momjian 2001-04-08 04:19:51 Re: Better Features document?