表字段的国际化

时间:2012-10-14 19:28:22

标签: mysql database database-design internationalization logic

我正在学习数据库国际化,并且有一个“小”问题。

我有一个名为categories的表格,其中包含字段idnamedescription等字段。并且,表格products也包含字段idcategory_idnamedescription以及其他字段。

categories table
id | name | description | ...others

products table
id | category_id | name | description | ...others

我需要将这些(和其他)表格国际化。因此,开始方法是创建另外三个表并更改第一个表。

languages table
id | name | code

categories table
id | ...others

category_languages table
id | category_id | language_id | name | description

products table
id | category_id | ...others

product_languages table
id | product_id | language_id | name | description

那么,主要的问题是:有办法将本地化“集中”在一个表中吗?我忘了什么?

谢谢!

1 个答案:

答案 0 :(得分:2)

您可以在一个表中添加翻译和翻译的标签,然后只需在每个表中添加一个新列,即翻译的标签。您将有一个名为translation的表,其中id列可以是标签和翻译列:

id | label | translation | language_id

并在每张桌子中:

id | some columns | translation_label