Re: Alias "all fields"?

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: Franz(dot)Rasper(at)izb(dot)de
Cc: stefan(dot)schwarzer(at)grid(dot)unep(dot)ch, pgsql-general(at)postgresql(dot)org
Subject: Re: Alias "all fields"?
Date: 2007-09-06 14:07:52
Message-ID: 46E009B8.3030902@wildenhain.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Franz(dot)Rasper(at)izb(dot)de schrieb:
>> Make the table:
>
>> id | year | value
>> ---+------+------
>> 1 | 1970 | 23
>> 1 | 1971 | 25
>> 1 | 1972 | 28
>> ...
>> 2 | 1972 | 5
>> 3 | 1971 | 94
>> 3 | 1972 | 102
>
>> primary key: (id,year)
>> value not null
>> and be ready.
>> the import/update reasons are pretty easily solved
>> that way too.
>
> then your primary key will consists of two fields.
> I prefer the primary keys with one field only.

Maybe but this would not help you with this situation here :-)
I think this fittes best but I'm open to alternative approaches.

The wide-table of the original design has definitively much more
problems. And if id is independent from year (not really month or
so) it is usefull imho to have a compound primary key.

Alternatively you can skip the primary key part and just define:

id not null,
year not null,
value not null

unique (id,year)

Regards
Tino

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-09-06 14:39:23 Re: Alias "all fields"?
Previous Message Franz.Rasper 2007-09-06 13:59:38 Re: Alias "all fields"?