pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aaron Bono <postgresql@aranya.com>
To: operationsengineer1@yahoo.com <operationsengineer1@yahoo.com>
Cc: Davi Leal <davi@leals.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Foreign Key: what value?
Date: Thu, 6 Jul 2006 14:32:45 -0500
Message-ID: <bf05e51c0607061232k54a9578dhdcc8fa6795d952b7@mail.gmail.com> (raw)
In-Reply-To: <20060706184634.50283.qmail@web33314.mail.mud.yahoo.com>
References: <200607051719.27466.davi@leals.com>
	<20060706184634.50283.qmail@web33314.mail.mud.yahoo.com>

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

view thread (4+ messages)

Message-ID: <bf05e51c0607061232k54a9578dhdcc8fa6795d952b7@mail.gmail.com>
Permalink:  ../bf05e51c0607061232k54a9578dhdcc8fa6795d952b7@mail.gmail.com/
Also on:    postgresql.org/message-id/bf05e51c0607061232k54a9578dhdcc8fa6795d952b7@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: postgresql@aranya.com, operationsengineer1@yahoo.com, davi@leals.com
  Subject: Re: Foreign Key: what value?
  In-Reply-To: <bf05e51c0607061232k54a9578dhdcc8fa6795d952b7@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox