Creating a realtionship with multiple columns

Forum for posting problems using QxEntityEditor

Creating a realtionship with multiple columns

Postby arolin » Wed Jun 25, 2014 10:12 pm

I have two entities:

Entity1:
    Entity1_Id
    Token
    SubToken

    Time

Entity2:
    Entity2_Id
    Token
    SubToken

    Description

Token and sub-token essentially make for a single key into entity2 so there is an N-1 relationship between Entity1 and Entity2 for the combined Token and Subtoken property. I am not sure how to model this correctly as it appears to me that the relationships point to the primary key of the target entity.

Thanks!
arolin
 
Posts: 3
Joined: Wed Jun 25, 2014 9:52 pm

Re: Creating a realtionship with multiple columns

Postby qxorm » Thu Jun 26, 2014 7:25 am

Hello,

Token and sub-token essentially make for a single key into entity2

So if I understand well, token + sub-token should be your primary key in entity2, and you should remove the Entity2_Id property.
token + sub-token becomes a 'multi-columns primary key' (or composite key).

About QxOrm library and composite keys, there is :
- more details in the FAQ here : http://www.qxorm.com/qxorm_en/faq.html#faq_101
- a sample project in ./test/qxBlogCompositeKey/ directory of QxOrm package

And to define a composite key in QxEntityEditor, you have to :
- token + sub-token is just a single property (instead of 2 properties) ;
- in the 'Column name' field of entity params window (or property params window), put the following value : Token|SubToken
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxEntityEditor - Help

Who is online

Users browsing this forum: No registered users and 4 guests