什么是多语言数据库设计的最佳实践?

什么是多语言数据库设计的最佳实践?

创建多语言数据库的最佳方法是什么?为每个表创建本地化表使设计和查询变得复杂,在其他情况下为每种语言添加列很简单但不动态,请帮助我理解什么是企业应用程序的最佳选择



UYOU
浏览 1284回答 3
3回答

叮当猫咪

我们所做的是为每个多语言对象创建两个表。例如,第一个表仅包含与语言无关的数据(主键等),第二个表包含每种语言一个记录,包含本地化数据和语言的ISO代码。在某些情况下,我们添加一个DefaultLanguage字段,这样如果没有可用于指定语言的本地化数据,我们就可以回退到该语言。例:Table "Product":----------------ID&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: int<any other language-neutral fields>Table "ProductTranslations"---------------------------ID&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: int&nbsp; &nbsp; &nbsp; (foreign key referencing the Product)Language&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: varchar&nbsp; (e.g. "en-US", "de-CH")IsDefault&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : bitProductDescription : nvarchar<any other localized data>使用此方法,您可以根据需要处理多种语言(无需为每种新语言添加其他字段)。

胡子哥哥

我觉得这种方法适合我:产品产品详细信息国家========= ================== =========ProductId ProductDetailId CountryId-&nbsp; etc&nbsp; -&nbsp; ProductId CountryName&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CountryId语言&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 产品名称 - 等 -&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 产品描述&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - 等 -&nbsp;ProductDetail表包含您要支持的语言的所有翻译(对于产品名称,描述等)。根据您应用的要求,您可能希望将Country表分解为使用区域语言。
打开App,查看更多内容
随时随地看视频慕课网APP