Re: design

Поиск
Список
Период
Сортировка
От Brett W. McCoy
Тема Re: design
Дата
Msg-id Pine.LNX.4.30.0101301145380.10014-100000@chapelperilous.net
обсуждение исходный текст
Ответ на design  (Jeff <jeff4e@rochester.rr.com>)
Список 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.


В списке pgsql-general по дате отправления:

Предыдущее
От: Matthew
Дата:
Сообщение: RE: design
Следующее
От: KuroiNeko
Дата:
Сообщение: Re: design