Hi Gurus,
I have a design/programming question. First I wanna ask if my design is good and then I wanna know how to.
What I wanna do is to have an i18n page, which may or may not have a translation. e.g. Page A has English & Japanese, and Page B may only have English
This is the DB layout
page
----
id int
topic varchar(128)
content varchar(1024)
page_l10n
---------
id int fk
topic varchar(128)
content varchar(1024)
locale_id int fk
locale
------
id int
name varchar(8)
To select, I do something like this
SELECT
COALESCE (hl.topic,h.topic) , COALESCE(hl.content, h.content)
FROM page h
LEFT JOIN (page_l10n hl, `locale` l) ON (h.id=hl.id AND l.id=hl.locale_id) AND l.locale = 'ja_JP'
So my question is, if this is an ok db layout (or do you guys suggest to use 2 table only and have the locale as a column in the page table? or other way of doing it?), how do I do my model (POJO)?
I am using JPA for R/O mapping and hibernate for the DB connection.
Please Advise Thanks in advance~