Inheritance and Constraints

Поиск
Список
Период
Сортировка
От Andrew Vit
Тема Inheritance and Constraints
Дата
Msg-id 1058405584.3f15fcd0cb124@webmail.telus.net
обсуждение исходный текст
Ответы Re: Inheritance and Constraints  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-general
Greetings to the local gurus,

I'm building a set of child tables that take their pkey (id) from a serial
column in the parent table. Now I want to create a separate table for a
many:1 relation with one of the child table rows:

--Simplifying greatly here:

CREATE TABLE products (
  id   serial      NOT NULL PRIMARY KEY,
  name varchar(64) NOT NULL,
);

CREATE TABLE thing_1 (
  foo  smallint,
  bar  text,
) inherits (products);

CREATE TABLE grading (
  thingid  int NOT NULL REFERENCES thing_1 (id),   --this is the problem.
  userid   int NOT NULL REFERENCES users (id),
  vote     smallint NOT NULL,
  PRIMARY KEY (thingid, userid)
)

I'm having trouble trying to create the foreign key that references the
inherited id in my child table. Is this possible to do? Or can the id only
be referenced to the parent table? Is there another (better) way to check
this constraint?

Thanks,
Andrew Vit



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

Предыдущее
От: Annabelle Desbois
Дата:
Сообщение: Transactions
Следующее
От: Tilo Schwarz
Дата:
Сообщение: ERROR: Memory exhausted in AllocSetAlloc(188)