Inheritance of Ref Integ

From: <caseman(at)mad(dot)scientist(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Inheritance of Ref Integ
Date: 2000-06-30 16:38:33
Message-ID: 000001bfe2b1$a23d7a50$14da7fa5@alfa_romeo.defenders.state.co.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have playing around with the new foreign key feature and found a problem
that I could not solve effectively:

I have a table called request that contains basic expense request data.
Four other tables 101_request, 102_request, 103_request and 104_request are
subclasses of the request table and add different data fields to the basic
request.
Another table payment contains payment information for all requests. It
contains the request id as a foreign key. I would like to use the foreign
key contraint on it, but have not been able to figure out how or if you can
and get the child tables to inherit it.

I tried the following which does not work (among others):

CREATE TABLE payment (
id SERIAL PRIMARY KEY,
req_id INT4 NOT NULL REFERENCES request*(id) ON DELETE CASCADE,
date DATE NOT NULL,
amount MONEY NOT NULL,
note TEXT
);

Doing a reference to request alone does not pass the reference down to the
child tables. Is it even possible to do what I want?

I know I could just divide this up into separate tables to make it work, but
using inheritance seemed like a *cleaner* method in my mind. Any insights
are appreciated.

-Casey Duncan

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2000-06-30 17:51:51 Re: Comments with embedded single quotes
Previous Message Tom Lane 2000-06-30 16:21:10 Re: disk backups