When to use name verses id

From: Lewis Bergman <lbergman(at)abi(dot)tconline(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: When to use name verses id
Date: 2002-02-04 14:51:57
Message-ID: 200202041451.g14Epvq11659@lewis.abi.tconline.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I got some very helpful suggestions last time I posted and have reworked my
entire db as a result.

I did away with a bunch of tbName for tables type stuff and a ton of pkName
and fkName for key columns. Thanks for the help and the design actually looks
a lot cleaner now.

My situation and question is now this:

I have some columns that I want to make sure have valid names in them.
For example one column refers to a foreign key which is a table containing
valid privilage access names like admin, user, agent, etc.... This
access_privilage table also has a serial column.

I guess my question is this. Should I _always_ refer to a serial or id type
of field or is there an appropriate time to refer to a name that the id
points to?

Do I even need an id column if I make the name column unique?

I used the suggestion made earlier when I needed a table to contain unique
names but each name needed multiple rows, That table only uses serial id's of
the referenced tables. I see the logic here because this table is "internel"
so to speak and won't be searched or reported on directly. These other tables
will be. Am I making sense here?
--
Lewis Bergman
Texas Communications
4309 Maple St.
Abilene, TX 79602-8044
915-695-6962 ext 115

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2002-02-04 16:00:16 Re: When to use name verses id
Previous Message Duncan Adams (DNS) 2002-02-04 13:30:43 Re: can u do three tables in left join?