Обсуждение: How would I store little key-Nr to text lists?

Поиск
Список
Период
Сортировка

How would I store little key-Nr to text lists?

От
Andreas
Дата:
  Hi

how would I store little key-Nr  to  text  lists?
Like e.g.

colors
1  red
2  green
3  blue

Maybe I later also need to add  4 yellow?

Obviously the numbers are used for foreign keys in data tables and the 
texts appear in selects.
On the other hand users should chose from listboxes in an application so 
I need to be able to read the (key, ext) tupels.

For now I use 2 column tables that in selects get joined to a data table.

Is there a more clever way ?


Re: How would I store little key-Nr to text lists?

От
Pavel Stehule
Дата:
2010/7/10 Andreas <maps.on@gmx.net>:
>  Hi
>
> how would I store little key-Nr  to  text  lists?
> Like e.g.
>
> colors
> 1  red
> 2  green
> 3  blue
>
> Maybe I later also need to add  4 yellow?
>
> Obviously the numbers are used for foreign keys in data tables and the texts
> appear in selects.
> On the other hand users should chose from listboxes in an application so I
> need to be able to read the (key, ext) tupels.
>
> For now I use 2 column tables that in selects get joined to a data table.
>
> Is there a more clever way ?

you can use enums, you can use a hstore contrib module, but what you
doing is best

regards

Pavel Stehule


>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>