使用多种语言时如何设计表格 [英] How to design tables when using multiple languages

查看:247
本文介绍了使用多种语言时如何设计表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网站上使用多种语言时,您如何建议设计表?假设我们有一个名为product的表。那可能包含诸如SKU,价格,排序顺序和其他设置之类的内容。但是,名称和说明将以几种语言提供。这些文本是否应放在各个表格中,例如:

How do you suggest to Design tables when working with multiple languages on a site? Say for example that we have a table called product. That one might contain stuff like SKU, price, sort order and other settings. The name, and description however will be available in several languages. should these texts be in individual tables like:

tbl product_lang_zh_CN

product_id |名称| description

tbl product_lang_de

product_id |名称|说明

tbl product_lang_en
product_id | name | description
tbl product_lang_de
product_id | name | description

还是应将所有内容收集在一个表中?

tbl product_lang

product_id | lang |名称| description

Or should everything be collected in one table
tbl product_lang
product_id | lang | name | description

后者感觉更正确,并且如果添加新的语言,将保持数据库的完整性。桌子越来越大时,要牢记性能方面的差异吗?易于维护等

The latter feels more right and will keep the integrity of the database if a new language is added. Are there any difference in performance to keep in mind when the tables are growing large? Ease of maintenance etc

干杯

推荐答案

第二种设计肯定是更好。关于第一个的清晰提示:两个表具有相同的列,有关数据的事实在表的名称中( en, de)。

The second design is definitely better. Clear tip-offs about the first: the two tables have the same columns, and facts about the data are in the names of the table ("en", "de").

就性能而言,一张桌子甚至比两张(或更多张)更好。如果您创建了正确的索引(例如,您希望在lang上创建一个索引),则只需访问一张表即可找到任何产品的描述。

As far as performance goes, it might even be better with one table than two (or more). If you create the proper indexes (you'll want one on lang, for example), then only one table will need to be accessed to find the description of any product.

这篇关于使用多种语言时如何设计表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆