From: | "Aaron Bono" <postgresql(at)aranya(dot)com> |
---|---|
To: | "operationsengineer1(at)yahoo(dot)com" <operationsengineer1(at)yahoo(dot)com> |
Cc: | "Davi Leal" <davi(at)leals(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Foreign Key: what value? |
Date: | 2006-07-06 19:32:45 |
Message-ID: | bf05e51c0607061232k54a9578dhdcc8fa6795d952b7@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 7/6/06, operationsengineer1(at)yahoo(dot)com <operationsengineer1(at)yahoo(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | David Clarke | 2006-07-06 20:30:57 | Re: Alternative to serial primary key |
Previous Message | operationsengineer1 | 2006-07-06 18:46:34 | Re: Foreign Key: what value? |