This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi - here's the scenario I'd like to model: Our Employees can manage any number of Sub-Employees, and each has a Rank of seniority within that relationship. So, we have an Entity 'Employee' and an Entity 'EmployeeRel' with properties ParentId, ChildId and Rank. (We need the identity key of EmployeeRel to be ParentId + ChildId + Rank, rather than relying on an arbitrarily created id.) So, following the instructions about composite keys, I can create the EmployeeRel table. Where I'm coming unstuck is trying to work out what the associations I should create between EmployeeRel and the Employee table, and how to access the 'rank' property of the relationship. Any guidance please? Thanks. |
|
|
Because your relationships are going to back on parts of the composite key you will need to handle the associations manually by loading the associated records which match the Employee's Id, e.g. something like this assuming you want to abstract away the use of EmployeeRel:
There are a number of potholes with this type of approach though so be wary, here are some top of head ones:
To access the Rank property you can find this as a property underneath .Id on your EmployeeRel entity, e.g. employeeRel.Id.Rank
|
|
|
Okay, thanks. Looks like it's probably going to be simplest to use the built-in identity, rather than try and work with a composite key. Thanks. |
|