Re: When to use name verses id

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: lbergman(at)abi(dot)tconline(dot)net
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: When to use name verses id
Date: 2002-02-04 16:00:16
Message-ID: 2491.1012838416@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Lewis Bergman <lbergman(at)abi(dot)tconline(dot)net> writes:
> Do I even need an id column if I make the name column unique?

You could dispense with an ID column (and IMHO should do so) if you can
*guarantee* that the name column will always be unique. In a lot of
practical situations that falls down --- eg, you'd be foolish to assume
that a company will never have two employees named Tom Lane.

The main reason people tend to use arbitrarily-assigned ID values is so
they can be certain of having a unique primary key for the table, even
when the other identifying info turns out to be less unique than it
might at first seem.

Integer IDs are probably also more compact and faster to compare than
strings, but this effect is not so strong that it should govern your
decisions. If you don't really need an ID column, I think you're
better off without one.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2002-02-04 17:04:16 Re: limit of 16 on arguments to functons
Previous Message Lewis Bergman 2002-02-04 14:51:57 When to use name verses id