多语言数据库与实体框架4指导 [英] Multilingual Database with Entity Framework 4 Guidance

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

问题描述

我们正在创建一个需要允许多种语言的数据的大型电子商务数据库。例如,产品表将需要一个或多个名称,描述,MetaTitle,MetaKeywords,MetaDescription等的翻译。



有几种方法可以从关系数据库设计的立场。但是实体框架4增加了一些约束,性能是一个很大的问题。



类似的问题在多语言数据库设计



这里是一组示例表正在考虑:

  [产品] 
- Id(PK)
- CreateDate
- NamePhraseId(FK)
- DescriptionPhraseId(FK)
- 价格
- ...

[短语]
- id(PK)
- 不变量

[翻译]
- id(PK)
- PhraseId(FK)
- LanguageCulture(示例:en-US)
- 翻译

我们还可以添加一个LanguageCulture查找表。



这种方法有其他方法的优缺点。我们不想为可能需要翻译的每个表列创建其他表(不包括ProductName,ProductDescription表),因为这将使我们的数据模型太大。



在上面的示例中,产品名称将具有一个或多个翻译的零个或一个短语。我记得,实体框架要求1到1个关系具有相同的主键,我不知道这是否与0或1关系相同,但这可能是上述方法的破产者。 >

我真的很难找到关于实体框架和多语言数据库/模型设计指导的良好信息。我将非常赞赏建议和指导,重点在于良好的设计和最佳性能。



提前感谢

解决方案

鉴于EF4的POCO支持,我会说,您的数据库的设计应该与EF有关,更适用于良好的多语言设计。



根据文档,EF支持零或一关系。只需将 PhraseId Translation 表中为空,那么应该会导致0..1关系。


We are creating a large e-commerce database that needs to allow for data in multiple languages. For example, the product table will need one or more translations for Name, Description, MetaTitle, MetaKeywords, MetaDescription and so on.

There are several ways to accomplish this from a relational database design standpoint. But Entity Framework 4 adds a few constraints and performance is a big concern.

Similar issue as in Multilingual Database Design

Here is an example set of tables we are considering:

[Product]
- Id (PK)
- CreateDate
- NamePhraseId (FK)
- DescriptionPhraseId (FK)
- Price
- ...

[Phrase]
- id (PK)
- Invariant

[Translation]
- id (PK)
- PhraseId (FK)
- LanguageCulture (Example: en-US)
- Translation

We could also add a LanguageCulture lookup table.

This method has it's pros and cons like other methods. We don't want to have to create additional tables for each table column that may require translation (no ProductName, ProductDescription tables for instance) as that would make our data model too large.

In the example above, a Product Name will have zero or one Phrases with one or more translations. As I recall, Entity Framework requires 1 to 1 relationships to have the same primary key on the tables, I don't know if that's the same case with 0 or 1 relationships but that may be a dealbreaker for the method above.

I've had a really hard time finding good information about Entity Framework and Multilingual database/model design guidance. I would greatly appreaciate advice and guidance with emphasis on good design and the best possible performance.

Thanks in advance!

解决方案

Given EF4's POCO support, I'd say the design of your database should have less to do with EF and more to do with good Multilingual design.

According to the documentation, EF supports "zero or one" relationships. Simply make the PhraseId in your Translation table nullable and that should result in a 0..1 relationship.

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

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