How to use multilanguage database schema with ORM?

artvolk picture artvolk · Jun 19, 2010 · Viewed 10.8k times · Source

Good day!

I'm searching for the best way to implement multilanguage database schema, the approach I use is the same 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!

Answer

Frosty Z picture Frosty Z · Jan 20, 2011

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