Define Entity Relationships
Key Lesson: In this step, you learn how to define relationships between header and detail entities so each record can access its related data.
With the transactional entities in place, configure the three relationship pairs required by the Purchasing app:
- PurchaseRequest ↔ PurchaseRequestItem
- Quotation ↔ QuotationItem
- PurchaseRequest ↔ Quotation
The following diagram shows the relationship direction and cardinality between the Purchasing entities.
This ERD illustrates how the transactional entities relate to one another and how they reference the shared Currency and CostCenter static entities across both header–detail structures.
Configure the entity relationships
Section titled “Configure the entity relationships”Configure the many-to-one relationship first, then add the corresponding one-to-many relationship and select the first relationship as its inverse.
1. PurchaseRequest ↔ PurchaseRequestItem Relationship
Section titled “1. PurchaseRequest ↔ PurchaseRequestItem Relationship”- Open the PurchaseRequestItem Entity Editor.
- Navigate to ENTITY RELATIONSHIPS and click +.
- Add the following relationship:
| Setting | Value |
|---|---|
| NAME | request |
| TARGET ENTITY | Purchasing.PurchaseRequest |
| RELATION TYPE | many-to-one: Many instances of this Entity have a relationship to a single instance of the target Entity (e.g. Address → Person) |
-
Leave all other properties at their default values.
-
Save and close the editor.
-
Next, open the PurchaseRequest Entity Editor.
-
In ENTITY RELATIONSHIPS, click + and add:
| Setting | Value |
|---|---|
| NAME | items |
| TARGET ENTITY | Purchasing.PurchaseRequestItem |
| RELATION TYPE | one-to-many: One instance of this Entity has a relationship to multiple instances of the target Entity (e.g., Person → Address) |
-
Leave all other properties at their default values.
Tip
If the INVERSE RELATIONSHIP dropdown is empty, press F5 to refresh the Entity Editor, then check the dropdown again.
-
Save and close the editor.
2. Quotation ↔ QuotationItem Relationship
Section titled “2. Quotation ↔ QuotationItem Relationship”- Open the QuotationItem Entity Editor.
- Add a new relationship:
| Setting | Value |
|---|---|
| NAME | quotation |
| TARGET ENTITY | Purchasing.Quotation |
| RELATION TYPE | many-to-one: Many instances of this Entity have a relationship to a single instance of the target Entity (e.g. Address → Person) |
-
Leave all other properties at their default values.
-
Save and close the editor.
-
Next, open the Quotation Entity Editor.
-
Add a new relationship:
| Setting | Value |
|---|---|
| NAME | items |
| TARGET ENTITY | Purchasing.QuotationItem |
| RELATION TYPE | one-to-many: One instance of this Entity has a relationship to multiple instances of the target Entity (e.g., Person → Address) |
-
Leave all other properties at their default values.
-
Save your changes before continuing.
3. Quotation ↔ PurchaseRequest Relationship
Section titled “3. Quotation ↔ PurchaseRequest Relationship”- Keep the Quotation Entity Editor open.
- In ENTITY RELATIONSHIPS, click + and add:
| Setting | Value |
|---|---|
| NAME | purchaseRequest |
| TARGET ENTITY | Purchasing.PurchaseRequest |
| RELATION TYPE | many-to-one: Many instances of this Entity have a relationship to a single instance of the target Entity (e.g. Address → Person) |
-
Leave all other properties at their default values.
-
Save and close the editor.
-
Next, open the PurchaseRequest Entity Editor.
-
In ENTITY RELATIONSHIPS, click + and add:
| Setting | Value |
|---|---|
| NAME | quotations |
| TARGET ENTITY | Purchasing.Quotation |
| RELATION TYPE | one-to-many: One instance of this Entity has a relationship to multiple instances of the target Entity (e.g., Person → Address) |
-
Leave all other properties at their default values.
-
Save and close the editor.