Search Postgresql Archives

foreign key constraints and inheritence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux