开发者

How to use multilanguage database schema with ORM?

Good day!

I'm searching for the best way to implement multilanguage database schema, the approach I use is the same开发者_StackOverflow as here: What are best practices for multi-language database design? (one table with language neutral data and one for all translation). It seems to be good and clean and doesn't limit number of possible languages.

But I want to use a simple ORM (like LINQ in C#, Outlet for PHP etc) where each table is mapped to entity class. This can work, but queries became more complex.

May be there are some special techniques to use such DB shema with ORM? Or I can benefit from more complex ORMs which support more complex mappings?

Thanks in advance!


Using only one table for all translations may quickly lead to severe performance and complexity issues for any operation (select/insert/update/delete) ; just try it to understand what I mean.

I would then go for the following method (two tables per "translatable" object), which seems a good balance between performance, complexity, and maintenance issues.

product
  - id (PK)
  - number1
  - number2
  - date1
  - date2
  ...

product_i18n
  - id (PK)
  - product_id (FK)
  - language_id (FK)
  - string1
  - string2
  ...

language
  - id (PK)
  - name

Check how it's done with Propel ORM (PHP) : http://propelorm.org/blog/2011/01/11/propel-gets-i18n-behavior-and-why-it-matters.html

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜