使用多种语言时如何设计表格

编程入门 行业动态 更新时间:2024-10-22 17:34:43
本文介绍了使用多种语言时如何设计表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在网站上使用多种语言时,您如何建议设计表?假设我们有一个名为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.

更多推荐

使用多种语言时如何设计表格

本文发布于:2023-10-18 13:07:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504311.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表格   多种   语言

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!