prefetchpath and non FK-PK tables

Posts   
 
    
Karim
User
Posts: 14
Joined: 17-Dec-2007
# Posted on: 23-Jan-2008 14:07:48   

Hi,

I have a table with mutable studentinformation and a table with non-mutuable studentinformation that get's filled from another system. Both tables are in the same database. Mutable-Table has a PK named ID and a kolom 'StudentNumber'. Unmutable-Table has a PK ID and a kolom 'StudentNumber'. Both StudentNumber are identical, but there is no relation defined.

What's the best way to get all of the Un-Mutable information as an entity of the corresponding Mutable student-entity. Can i define a new relation between the tables and then prefetch it through the newly defined relation. That would be nice.

Kind regards, Karim

PS: I am at the moment not able to make changes to the datamodel. Otherwise that whole ID column would have been removed as the 'StudentNumber' is unique and i don't need to add new students, i just need to adjust the Mutable columns.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 23-Jan-2008 15:31:41   

Relations can be custom created in the designer using a PK field on either side of the tables. In your case no PK is envolved in the relation, then you won't be able to define a relation at design time, and so you won't be able to add a field mapped on this relation.

But you can create a custom relation at runtime between any 2 fields in the database in order to make a JOIN needed for a query.

If I were in your shoes, I'd do the following:

In the database: 1- Create a View to capture the non-mutuable studentinformation without it's PK

In the LLBLGen Pro Designer: 2- Map it to LLBLGen Pro as an entity, and manually set the 'StudentNumber' as the PK. 3- Define a custom relation between both tables using the 'StudentNumber' field.