Re: Foreign Key: what value?

Поиск
Список
Период
Сортировка
От Aaron Bono
Тема Re: Foreign Key: what value?
Дата
Msg-id bf05e51c0607061232k54a9578dhdcc8fa6795d952b7@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Foreign Key: what value?  (<operationsengineer1@yahoo.com>)
Список pgsql-sql
On 7/6/06, operationsengineer1@yahoo.com <operationsengineer1@yahoo.com> wrote:
i alsways make my foreign key column data type int4.
i'm not sure if i read that somewhere.  anyone, please
feel free to chime in if this isn't good practice.

read up on currval, nextval and that whole section.
you can begin by getting the nextval, assigning it to
a variable, insert it into your primary table and then
insert it into your related table as a foreign key.

from what i understand, either way should be
bulletproof.  the way i described is more code, but
some minds might not mind paying that price b/c they
like the process better.

good luck.

Bigserial's are simply bigint's with a sequence that does the nextval part for you.  Your approach works but takes more coding on your part.  I would recommend using bigserial so you cut some of the work out for yourself.

-Aaron

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

Предыдущее
От:
Дата:
Сообщение: Re: Foreign Key: what value?
Следующее
От: "David Clarke"
Дата:
Сообщение: Re: Alternative to serial primary key