Entites in different languages

Posts   
 
    
fstorz
User
Posts: 3
Joined: 13-Jun-2011
# Posted on: 13-Jun-2011 15:18:35   

Hello

I'm designing entites in different languages. Each of those entites has one Text field i need to store in different languages. So i did a DB-Design like this one:

tbl_Entity1

EntityId SomeOtherFields...

Then a localistation Table:

tbl_localisation

Id TextField EntityType EntityId Language

Now i can join on EntityType and EntityId to get a text of an entity in a specific language.

My problem is how to design this, for the best use with llblgen. If i use a stored procedure, that would be easy on the DB side, but i have to wrap all entites after i got them from the DB throu the stored procedure. I can use a view, but this is very complex (or even not possible?!) on the DB side.

What do you think about this?

Thanks and best regards

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 13-Jun-2011 16:56:54   

Option 1: Use a separate localization table for each entity.

Option 2: Let all entities inherit from a base entity (table) which only has EntityId, and EntityType both are PK fields. (You can also use an artificial PK).

Then the localization atble would reference this main table. This has the advantage of maintaining the refrential integrity between the localization table and the entities.

fstorz
User
Posts: 3
Joined: 13-Jun-2011
# Posted on: 14-Jun-2011 07:53:47   

Thanks for your answer.

Option 1: Use a separate localization table for each entity.

I think this is what i do with my design expect i use one table for each entity. My problem is to get the data correctly from the datebase.

Example: Entity 1 has a localisation in EN (default for application) and in DE. I can get the localisation in DE easy.

Entity 2 has only a localisation in EN and i try to get the localisation for DE. Here i have the problem, that i don't get any result beacause the DE localisation does not exists and i would like to get the EN localisation returned.

As i said, if i do this logic with a stored procedure this is not a problem, but i'd like to this with a view. Is this even possible?

Thanks for your help!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Jun-2011 08:17:40   

If you have to put it in a single query it would contain a join and a coalesce. Example: http://stackoverflow.com/questions/189680/database-localization

You can use coalesce using a LLBLGen DBFunction call.

David Elizondo | LLBLGen Support Team