上的项目,我有如下表:查找表本地化
create table dbo.Posts
(
Id int identity not null primary key clustered (Id),
Created datetime not null,
);
create table dbo.PostsLocalized
(
Id int identity not null primary key clustered (Id),
PostId int not null,
LanguageId int not null,
PostTypeId int not null,
[Text] nvarchar (max) not null,
Title nvarchar (120) not null,
constraint UQ_PostsLocalized_PostId_LanguageId unique (PostId, LanguageId)
);
create table dbo.PostTypes
(
Id int identity not null primary key clustered (Id),
Name nvarchar (max) not null
);
所以我用PostsLocalized表本地化的职位,但不是PostTypes表。
PostTypes表基本上是一个查找表,就像其他人在我的数据库中一样。
你认为我应该本地化查找表,例如PostTypes?
我会添加一个名为PostTypesLocalized与本地化名称的新表。
同样对于像性别,其他国家的查找表,...
或者我应该只在应用本地化的查找表?
UPDATE
澄清:
一个职位的所有本地化版本具有相同的PostType。
我需要在UI中显示PostTypes,这就是为什么我需要翻译它们。
所以,我想@dasblinkenlight的回答以下的新方法:
create table dbo.Posts
(
Id int identity not null primary key clustered (Id), -- The id of the localized post
Created datetime not null,
PostId int not null, -- The id of the post
PostTypeId int not null
LanguageId int not null,
[Text] nvarchar (max) not null,
Title nvarchar (120) not null,
constraint UQ_PostsLocalized_PostId_LanguageId unique (PostId, LanguageId)
);
create table dbo.PostTypes
(
Id int identity not null primary key clustered (Id), -- PostType localized id
PostTypeId int not null, -- The id of the post type
Name nvarchar (max) not null
);
考虑到(1)再上岗> PostTypeId应与PostTypes> PostTypeId。
但我该怎么做?
我还建议您使用有意义的名称作为主键而不是ID。简单的ID不明确,迫使你根据他们所在的表格来更改列的名称。随着系统变得更大,这是一个非常痛苦的工作。给他们一个有意义的名字并保持一致。 – 2014-09-11 14:09:28
@SeanLange,对不起在哪张桌子? – 2014-09-11 15:01:29
所有这些。例如,您在帖子命名标识中有一列,它在其他表中成为PostID。只需在每个表格中将其命名为PostID即可。与所有其他键一样。 – 2014-09-11 15:05:15