如何设计多种语言的数据库? [英] How to design database for multi languages?

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

问题描述

向专家问好

我想为几种语言设计一个数据库,但是我有疑问吗?
在此数据库中,有保存为多种语言的用户信息.
例如:

用户ID,名字,姓氏,传记

如何设计?

非常感谢

Hi to Experts

I want to design a DB for several language, but I have question?
In This DB there are user information that saved to several languages.
for example:

UserID, FirstName, LastName, Biography

How to I design it?

thanks a lot

推荐答案

我无法想象您的意思是名字和姓氏之类的东西都会被本地化.对于诸如传记之类的列,您将需要创建具有诸如列之类的另一个表. Id,lcid,文本,其中Id当然是该表的标识符,lcid是语言代码,文本是本地化文本.然后在此表和用户表之间创建一个联接表,并根据lcid进行选择以获取所需的本地化文本.
I can''t imagine you mean things like first name and last name would be localized. For columns such as biography you would need to create another table with columns such as; Id, lcid, text, where I''d is of course the identifier for this table, lcid is the language code and text is the localized text. Then create a join table between this and the user table and select based on the lcid to get the localized text needed.


您的数据库设计需要进行另一处更改.使用NVarchar代替Varchar,因为它允许对字符使用unicode.
Your database design needs another change. Use NVarchar instead of Varchar, as it allows the use of unicode for characters.


您告诉我,我对数据库的设计如下:

创建表UserName(UserID int IDENTITY PRIMARY KEY NOT NULL)



创建表语言(LanguageID int IDENTITY PRIMARY KEY NOT NULL,

语言描述varchar(50)NOT NULL)





创建表UserAttrib(UserID int非空,外键引用UserName(UserID),

LanguageID int NOT NULL外键引用Language(LanguageID),

FisrtName varchar(100)NOT NULL,

姓氏varchar(100)NOT NULL

--etc.)
You are telling me that I design the database as follows:

CREATE TABLE UserName(UserID int IDENTITY PRIMARY KEY NOT NULL)



CREATE TABLE Language (LanguageID int IDENTITY PRIMARY KEY NOT NULL,

LanguageDescription varchar(50) NOT NULL)





CREATE TABLE UserAttrib (UserID int NOT NULL FOREIGN KEY REFERENCES UserName(UserID),

LanguageID int NOT NULL FOREIGN KEY REFERENCES Language(LanguageID),

FisrtName varchar(100) NOT NULL,

LastName varchar(100) NOT NULL

--etc.)


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

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