foreign key constraints and inheritence

Поиск
Список
Период
Сортировка
От Garrett Kalleberg
Тема foreign key constraints and inheritence
Дата
Msg-id 59057EB0-2099-4C9F-AAE4-67E6DEE917BD@metadada.com
обсуждение исходный текст
Ответы Re: foreign key constraints and inheritence  (Michael Fuhr <mike@fuhr.org>)
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: encoding and locale
Следующее
От: "Michael Schmidt"
Дата:
Сообщение: Re: How to create unique constraint on NULL columns