How to create a 1:1 relation

Posts   
 
    
ww
User
Posts: 83
Joined: 01-Oct-2004
# Posted on: 06-May-2009 18:34:29   

How do you create a 1:1 relation in the designer?

I have a Customer table and a CustomerStats stats table that should be in a 1:1 relationship. They can't share the same PK because each inherits from a common base class, using the Target-Per-Entity model. So instead either the Customer has an FK to the CustomerStats or vice-versa. In llblgen this results in an 1:N relation on one side, which is cumbersome: if Customer has an FK to CustomerStats, CustomerStats has a "Customers" collection rather than a single Customer, so I have to do a collection fetch and take the first member. Is there a way to tell the designer to make this a 1:1 relation?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-May-2009 05:47:48   

You need to place a unique constraint on the relevant connected field of the FK side.

David Elizondo | LLBLGen Support Team
ww
User
Posts: 83
Joined: 01-Oct-2004
# Posted on: 07-May-2009 15:27:26   

Excellent. Thanks.