问题
I have to design a database which will allow me store data in multiple languages. I came up with something like this.
create table lang ( id primary key, lang_code ) create table data (id primary key) create table i18n_data (id primary key, i18n_text ,data_id references data, lang_id references lang)
Is creating a table with only one column/primary key is an overkill for my requirement? Is there any better way to do it?
Thanks.
回答1:
I think that your solution is a quite nice one, I am solving such problems the same way. And I wouldn't fear to create a table only with a primary key (although you might find a few attributes which are belonging to this table).
回答2:
On the top of my head I see two similar options:
Having just two tables lang
and i18n_data
and an indexed field in i18n_data
that you use with the language to index the translation.
Another option could be to use a composed primary key on the i18n_data
table that has the reference to lang
and the data
identifier.
来源:https://stackoverflow.com/questions/9960241/i18n-using-database