Re: Database design problem: multilingual strings

Поиск
Список
Период
Сортировка
Искать
От
Ernest E Vogelsinger
Тема
Re: Database design problem: multilingual strings
Дата
Msg-id
5.1.1.6.2.20030624192243.03d6be80@mail.vogelsinger.at
Ответ на
Список
Дерево обсуждения
Database design problem: multilingual strings Antonios Christofides <A.Christofides@itia.ntua.gr>
warning: long, Re: Database design problem: multilingual strings Karsten Hilbert <Karsten.Hilbert@gmx.net>
Re: Database design problem: multilingual strings Dennis Gearon <gearond@cvc.net>
Re: Database design problem: multilingual strings Ernest E Vogelsinger <ernest@vogelsinger.at>
Re: Database design problem: multilingual strings Russ Brown <postgres@dot4dot.plus.com>
At 19:15 24.06.2003, Antonios Christofides said:
--------------------[snip]--------------------
>'description' is no longer enough; it must be possible to add
>translations to _any_ language and to any number of languages.
>I've thought of a number of solutions, but none satisfies me to the
>point that I'd feel ready to die :-) I'd much appreciate
>comments/experience from anyone. I include the solutions I've thought
>of below, but you don't need to read them if you have a good
>pointer in hand.
--------------------[snip]-------------------- 

Taking off from this table:

table cutlery_types
id description 
---------------- 
1 Spoon 
2 Fork 
3 Knife 
4 Teaspoon

you might use a table set like this:

table lg_dependent
oid_table | column | id_row | language | text
---------------------------------------------------
######### | desc   |      1 | en       | Spoon
######### | desc   |      1 | ger      | Löffel
######### | desc   |      1 | fr      | Cuilliere 
######### | desc   |      1 | el      | Koutali

Use a select statement like this:

select t1.id, t2.text /*, etc */
from cutlery_description t1
join lg_dependent t2 on t2.oid_table = (select oid from pg_class where
relname='cutlery_types') and t2.column='desc' and t2.language='en'

It might be better to _not_ use the table oid to be more portable across
databases, or pg_dumps without OID. You might either use the table name
then, or have another table mapping table names to unique numbers.






-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/


В списке pgsql-general по дате отправления
От: Karsten Hilbert
Дата:
От: Stephan Szabo
Дата:
Сообщение: Re: Inheritance & Indexes
FAQ