构建多语言数据库架构 [英] Building a Multi-Language DB Schema

查看:72
本文介绍了构建多语言数据库架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数据库= mySQL
开发平台= Java

我们正在尝试构建一个Web应用程序,并希望提供多语言支持,因此,当用户从登录页面选择一种语言时,所有项目,标签,列表项等都将以所选语言显示.

例如,我们有一个屏幕,可以在其中添加用户,并在此处收集大量数据.我们具有名字",姓氏"等字段.我们希望以选定的语言显示这些字段.

我们研究的一个选项是创建一个db表,该表包含系统中的所有标签,并为每种语言创建一个对应的列.像这样的东西:

表名称:List_Text
栏位1:lbl_text_id
栏位2:English_lbl_text
栏3:Spanish_lbl_text
领域4:...

我以某种方式认为,如果采用这种方法,将会遇到性能问题.我想看看我们是否可以就此事得到一些建议.非常感谢您的帮助.

谢谢.

解决方案

您是否需要在db表中包含该信息?信息没有改变-为什么不将其存储在简单的属性文件中?这也是提供多语言支持的常见方式.
这些文本文件也更易于分发给口译员.

使用JavaServer Pages技术开发多语言Web应用程序 [ Class ResourceBundle @ oracle.com [ 解决方案

Do you need to have that information in a db table? The information is not changing - why not store it in a simple properties file? That''s also the common way to provide multi language support.
Also are those text files much simpler to hand out to interpreters.

Developing Multilingual Web Applications Using JavaServer Pages Technology[^]

Class ResourceBundle @ oracle.com[^]

regards
Torsten


Although your aproach will work, i believe the best one is to create a table to hold the primary key of a content, a second table to hold the different languages, and then a third table to hold the translations for the 1st table:

ContentTable
- ContentId (PK)
- CreatedOn

LanguageTable
- LanguageId (PK)
- Title
- LanguageCode
- CreatedOn
- UpdatedOn
- IsActive

ContentTextTable
- ContentId (FK)
- LanguageId (FK)
- Title
- Text
- CreatedOn
- UpdatedOn
- IsActive

This aproach will allow you to upgrade the application and the database easily and without having to touch the code.

Yes, if you have a complex structure on your database already, you will find yourself with almost the double of the tables, but it compensates.

Guy Silva


这篇关于构建多语言数据库架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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