Re: design

From: "Brett W(dot) McCoy" <bmccoy(at)chapelperilous(dot)net>
To: Jeff <jeff4e(at)rochester(dot)rr(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: design
Date: 2001-01-30 16:51:11
Message-ID: Pine.LNX.4.30.0101301145380.10014-100000@chapelperilous.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 30 Jan 2001, Jeff wrote:

> I have a design question. Lets say we want to keep track of users and
> their respective snail mail addresses. Each user can have up to 4
> different mailing address. Is it better to have all this information in
> one table. Or is it better to have a user table and an address table,
> and have the user id as a foreign key in the address table?

I would put the addresses in a separate table and use the foreign key.
That way each user can have as many addresses as you want. A year from
now you might change your requirement to 5 addresses. Or perhaps you want
to keep historical information.

In general, if you find yourself designing a table where duplicate
information is showing up (in this case, if you had only used one table,
user names would have been entered 4 times, once for each address), you
need to apply normalization and break it into two (or more) tables.

-- Brett
http://www.chapelperilous.net/~bmccoy/
---------------------------------------------------------------------------
Health is merely the slowest possible rate at which one can die.

In response to

  • design at 2001-01-30 16:35:21 from Jeff

Responses

  • Re: design at 2001-01-28 17:15:48 from Adam Lang

Browse pgsql-general by date

  From Date Subject
Next Message KuroiNeko 2001-01-30 16:55:12 Re: design
Previous Message Bruce Momjian 2001-01-30 16:44:19 Re: LinuxWorld NYC