primary/foreigner keys

Поиск
Список
Период
Сортировка
От lcampos@ics.uci.edu (Luis Miguel Campos)
Тема primary/foreigner keys
Дата
Msg-id 5fa15e5f.0111211611.c4dd97b@posting.google.com
обсуждение исходный текст
Ответы Re: primary/foreigner keys  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-sql
Hi,
I am trying to do the following:
CREATE TABLE Customer (
customer_id SERIAL PRIMARY KEY;
account_id INTEGER UNIQUE REFERENCES Account DEFERRABLE);

CREATE TABLE Account (
account_id SERIAL PRIMARY KEY,
customer_leader_id INTEGER UNIQUE REFERENCES Customer DEFERRABLE);

Description:
I am trying to create two tables where several customers can belong to
an account and each account has a customer leader.
This involves having each tables primary keys to be the foreigner key
in the other table. (other solutions are welcome)

Problem:
First I can not create either table because the other is not known.
I tried even within a BEGIN; table creation; commit;
Secondly If I succeed how do I INSERT values into the tables?

I am sure someone has already faced such a problem, so there must be a
solution out there but I could not find it in the postgresql
documention.

Thank you for your help,
Miguel


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

Предыдущее
От: Joe McGuckin
Дата:
Сообщение: How to find missing values in a sequence ?
Следующее
От: Fernández Mariano
Дата:
Сообщение: Stored Procedure