Follow treslines by email clicking Here!

Sunday, June 9, 2013

Translation - Multilingual/Multilanguage Database Design

Hi there! Today i wanna share something very useful to you while developing a multilingual / multilanguage database (DB). While outthere is a lot of code and approches, none of them take the time to point out the details you need to know, to really understand the concept and how you may optimize it. In this post i'm trying to explain it and to show my solution to you in a very simple, grafical way. It may exists even better approches out there, but I think this is a good one.

Understanding the concept before otimization

first of all lets understand the concept. The image below is the best way to visualize my thoughts. so lets take a look of it:


Ok, let's point out what ist good and not so good in this approach.
+ you have all translations files in one place (better maintanance)
+ with every new language you may have or need, you don't need to change your entity tables (flexible, extenpandable)
- not very readable for the DB user and queries/inserts are not trivial
- I do not know the ranges of each table (for example, if i want to print out a specific table for the translator in my DB it may be very difficult at first sight)


How can i optimize this approach?

Well there is a way to do that. For example one of it is to define an insert schema. It will turn this approach into a very readable and enables everybody to search for a specific table range without big efforts. The second image below is the best way to explain what i mean. So lets take a look of it:





Have you figured out the trick? The idea here is to work with conventions.  The insert schema could be something like:

IdRowToTranslate_TableName_ColumnPropertyName_IdRowTranslationReference_TableName

in this concrete example:
1_PRODUCT_NAME_1_TRANSLATION_REFERENCE 
1_PRODUCT_DESCRIPTION_2_TRANSLATION_REFERENCE  

2_PRODUCT_NAME_3_TRANSLATION_REFERENCE 
2_PRODUCT_DESCRIPTION_4_TRANSLATION_REFERENCE
and so on...
 
Once defined the insert and its respective query commands, it turns the model into a much more readable and understandable approach. This way we are now also able to seach by ranges.


Update: 

Hi there! a few days ago,  i had an interesting contatct with Alessandro. A Software Engineer looking also for a multilingual / multilanguage database solution. He had a very good approach. We have discussed PROS and CONS and because i think, that his solution is even more elegant than mine, i asked him to post it here to complement this post and share his solution with us. Here are both solutions (mine and alessandro's solution), so you can directly compare and have an ideia how to do it. Thanks Alessandro for sharing it with us.






That's all. hope you like it.

2 comments:

  1. your images are not at all clear, please upload clear images that would be helpful to me.

    ReplyDelete
  2. Thanks for explanation.

    Is posible create a view like this with Alessandro. A Design?

    Products_VIEW
    id | Translation_TXT | Field | Lang | Price
    1 | Coffe................ | Name| EN | 10
    2 | 100% ARABICA | Desc | EN | 10
    3 | CAFE................| Name| PT | 10

    How? (Yes, I'm very noob with Joins)

    ReplyDelete