HOW TO map an Entity to a table dynamically

Posts   
 
    
Piedro
User
Posts: 24
Joined: 17-Jan-2007
# Posted on: 06-Feb-2007 16:36:13   

Hi all,

In multi-company / multi-country databases (like Peoplesoft, Navision, SAP) it is common practice to put the multi-country aware data in different tables, like Customers_NL, Customers_UK, ... or in a different schema NL.Customers, UK.Customers, ...

This means that the datalayer must decide at runtime to which table the entity must be mapped.

Is an architecture like this possible with LLBLGen Pro?

regards,

Peter

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 07-Feb-2007 08:20:26   

Are these tables, exist from the start, or they are dynamically created?

Also if these tables have different fields/structure, how would you map a class to any/all of them?

The best you can do is to have them inherit from a common table, and use Inheritance in LLBLGen Pro.

Piedro
User
Posts: 24
Joined: 17-Jan-2007
# Posted on: 07-Feb-2007 09:43:27   

These tables will have exactly the same structure. Only the name or schemaname will be different.

The main advantages of this architecture is that it's easier to set up security and replication on a country-level.

_Frankly I mainly see advantages for the dba, and none for the developer. So I give you one chance to guess who came up with the idea. wink _

The best you can do is to have them inherit from a common table, and use Inheritance in LLBLGen Pro.

What do you mean by 'inherit from a common table'? Do you mean in the definition of your database? We are using SQL Server 2005 and I don't know of any inheritance features like in PostgreSQL.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 12-Feb-2007 09:41:47   

You can only switch between schemas with identical tables, you can't switch at runtime from table A to table B for the same entity E if they're in the same schema.

Tables which represent the same entity, should be in different schemas if you have different types of data in them e.g. per country.

Frans Bouma | Lead developer LLBLGen Pro