From: | Philippe Lang <philippe(dot)lang(at)attiksystem(dot)ch> |
---|---|
To: | Thom Brown <thombrown(at)gmail(dot)com>, PGSQL Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Avoiding surrogate keys |
Date: | 2010-04-22 06:04:21 |
Message-ID: | 8AE5A725DAF7364F97FF75D99E45B65740B3A79A@SBS1.attiksystem.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I think nobody mentioned Object-Relational mappers. If you intend to used one (or think you may be using one in the future), using surrogate keys is more straightforward, if not necessary.
Best regards,
-------------------------------------------------------------
Attik System web : http://www.attiksystem.ch
Philippe Lang phone: +41 26 422 13 75
rte de la Fonderie 2 gsm : +41 79 351 49 94
1700 Fribourg pgp : http://keyserver.pgp.com
> -----Message d'origine-----
> De : pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-
> owner(at)postgresql(dot)org] De la part de Thom Brown
> Envoyé : mercredi 21 avril 2010 21:01
> À : PGSQL Mailing List
> Objet : [GENERAL] Avoiding surrogate keys
>
> I think I know what I plan to do, but want to throw this out there to
> see if there are differing points of view.
>
> I have a mailing list table, and 2 of the columns contain values which
> have to be from a list. These are country and status. There are 237
> possible countries and 3 possible statuses. Now I know some people
> would assign a sequence ID (surrogate key) to the country and status
> values, and have them looked up in separate tables to get the textual
> value, but I think I'll still have those tables, just without an ID
> column, so 1 column for both the countries and statuses tables. This
> means storing the proper value in the main table.
>
> So instead of
>
> name, email, country, status
> 'mr smith', 'emailaddress(at)example(dot)com', 44, 2
> 'mrs jones', 'me(at)emailcompany(dot)com', 21, 1
>
> I'd have
>
> name, email, country, status
> 'mr smith', 'emailaddress(at)example(dot)com', 'China', 'Registered'
> 'mrs jones', 'me(at)emailcompany(dot)com', 'Belgium', 'Unconfirmed'
>
> The values of course would be constrained by foreign key lookup to
> their associated tables.
>
> Are there any serious downsides to this? If so, what would you
> recommend?
>
> Thanks
>
> Thom
From | Date | Subject | |
---|---|---|---|
Next Message | John Gage | 2010-04-22 07:24:05 | Re: Identical command-line command will not work with \i metacommand and filename |
Previous Message | maksim.likharev | 2010-04-22 05:44:02 | pg 8.3 windows, DB curruption, out of space |