| From: | Garrett Kalleberg <experimental(at)metadada(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | foreign key constraints and inheritence |
| Date: | 2005-07-16 21:39:59 |
| Message-ID: | 59057EB0-2099-4C9F-AAE4-67E6DEE917BD@metadada.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
I have this structure:
CREATE TABLE invoicelineitemtypes (
invoicelineitemtypeid varchar(36) PRIMARY KEY,
otherstuff varchar(36)
);
CREATE TABLE invoicelineiteminventorytypes (
moresetuff varchar(36)
)
INHERITS (invoicelineitemtypes);
CREATE TABLE invoicelines (
invoicelineitemtypeid varchar(36) REFERENCES
invoicelineitemtypes ON DELETE CASCADE,
otherstuff varchar(36)
);
INSERT INTO invoicelineiteminventorytypes (invoicelineitemtypeid)
VALUES ('1234');
The following insert:
INSERT INTO invoicelines (invoicelineitemtypeid) VALUES ('1234');
invokes
"insert or update on table "invoicelines" violates foreign key
constraint "invoicelines_invoicelineitemtypeid_fkey"
Now, the rec with id '1234' is in the table
invoicelineiteminventorytypes, but I can't wrap my head around the
fact that
SELECT invoicelineitemtypeid FROM invoicelineitemtypes
yields the rec with invoicelineitemtypeid '1234', yet I can't
reference it in the invoicelines INSERT statement.
Am I missing something? Is there a workaround for this?
PostgreSQL 8.0.1 running on OS X 10.4.2.
Garrett
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Schmidt | 2005-07-16 21:58:29 | Re: How to create unique constraint on NULL columns |
| Previous Message | Patrick TJ McPhee | 2005-07-16 20:54:22 | Re: How to create unique constraint on NULL columns |