on 01-11-2024 6:34 AM
Hi Experts,
We have multiple entities which consists of several key fields in our CAPM application. How do we define foreign key relationships between entities?
I have 3 primary keys in my main entity Demo i.e. ID1,ID2,ID3. All these 3 keys make composite primary key.
Now once I create an association from Emp entity to Demo entity, then 3 default properties gets added in Emp entity i.e. toDemo_ID1, toDemo_ID2 and toDemo_ID3. But I do not want a default properties name, rather I need my own defined properties i.e. EmpID instead of toDemo_ID1, EmpId2 instead of toDemo-Id2 and EmpId3 instead of toDemo_ID3.
Below Is the entity format which we need. Please suggest how this can be acheived
entity Demo {
key ID1 : Integer;
key ID2: Integer;
key ID3: Integer:
…};
entity Emp {
toDemo: association to Demo;
EmpId1: referring to primary key ID1 of Entity Demo;
EmpId2: referring to primary key ID2 of Entity Demo;
EmpId3: referring to primary key ID3 of Entity Demo;
…};
entity Test {
toEmp: association to Emp;
TestId1: referring to EmpID1 of Entity Emp;
TestId2: referring to EmpID2 of Entity Emp;
TestId3: referring to EmpID3 of Entity Emp;
…};
Regards,
Adarsh
CDS supports you perfectly with this:
entity Demo {
key ID : Integer;
};
entity Emp {
key emp: association to Demo;
}
entity Test {
key test: association to Emp;
};
however, don't name the associations like the source entities, always give them semantically meaningful names (toDemo, etc)...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hans,
Thanks for your help and input.
As per your suggestion we changed the association name to a meaning full name. Thanks for highlighting the same. But I think my issue still exist.
I have 3 primary keys in my main entity Demo i.e. ID1,ID2,ID3. All these 3 keys make composite primary key.
Now once I create an association from Emp entity to Demo entity, then 3 default properties gets added in Emp entity i.e. toDemo_ID1, toDemo_ID2 and toDemo_ID3. But I do not want a default properties name, rather I need my own defined properties i.e. EmpID instead of toDemo_ID1, EmpId2 instead of toDemo-Id2 and EmpId3 instead of toDemo_ID3.
Below Is the entity format which we need. Please suggest how this can be achieved
entity Demo {
key ID1 : Integer;
key ID2: Integer;
key ID3: Integer:
…};
entity Emp {
toDemo: association to Demo;
EmpId1: referring to primary key ID1 of Entity Demo;
EmpId2: referring to primary key ID2 of Entity Demo;
EmpId3: referring to primary key ID3 of Entity Demo;
…};
entity Test {
toEmp: association to Emp;
TestId1: referring to EmpID1 of Entity Emp;
TestId2: referring to EmpID2 of Entity Emp;
TestId3: referring to EmpID3 of Entity Emp;
…};
A managed association is a structured element with the augmented semantics that the sub elements describe a relationship to the target. With this, a managed association underlies the same flattening rules than any other structured element. If you don't agree with this please model your own elements and use unmanaged associations (relinquishing a lot of convenience).
User | Count |
---|---|
77 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.