From: | kpub <kpub(at)actcom(dot)net(dot)il> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Multilingual db |
Date: | 2003-09-25 14:11:52 |
Message-ID: | 3F72F7A8.4090303@actcom.net.il |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I'm new to SQL/PostgreSQL programming so forgive me if my questions are
to dumb?
I'm designing a multilingual db and I don't know if I'm on the right track.
Please advise.
The basic structure of the tables:
Common Info
| id | ...
localize info
| id | lang | country | ...
Now here is what I came up with.
1. let the client do all the work of getting the right localize info:
SELECT * FROM table_name
WHERE id=1 AND ((lang='en' AND (country='US' OR country='')) OR
(lang='' AND country=''))
ORDER BY lang DESC, country DESC LIMIT 1;
2. Add function for retrieving the localized info:
get_local_info(id, table_name, lang, country);
Retrieve by:
SELECT * FROM get_local_info(1, 'table_name', 'en', 'US') AS (id
integer, lang char(2), country char(2), ...);
Q1. Is it possible somehow to use table definition as column definition
list in AS clause?
Q2. I'd like to simplify the query from section 1 to
SELECT * FROM table_name WHERE id=1 AND lang='en' AND
country='US' ;
For that purpose I need to trap the select query and handle it
by myself. Is it possible?
Q3. Is there a better way to approach the subject?
Thanks.
Yaniv.
From | Date | Subject | |
---|---|---|---|
Next Message | scott.marlowe | 2003-09-25 14:15:15 | Re: insert duplicated unique/PK with no errors |
Previous Message | Francois Suter | 2003-09-25 13:55:47 | Re: German translation of PostgreSQL documentation |