Entity Relationships
Entity relationships connect records that belong together. They allow screens, processes, expressions, and services to access related data through named properties instead of treating every record as an isolated object.
For example, a purchase request can be related to its line items and supplier quotations. These relationships make collections such as request.items and request.quotations available wherever the purchase request is used.
Relationship direction and cardinality
Section titled “Relationship direction and cardinality”Lowgile supports two relationship types:
- Many-to-one: Multiple records relate to one target record. For example, multiple
PurchaseRequestItemrecords can reference onePurchaseRequestthrough a relationship namedrequest. - One-to-many: One record relates to multiple target records. For example, one
PurchaseRequestcan expose its relatedPurchaseRequestItemrecords through a relationship nameditems.
The relationship type describes the direction from the current entity to the target entity. The same association can therefore be represented from both sides:
| Current entity | Relationship | Target entity | Type |
|---|---|---|---|
PurchaseRequestItem | request | PurchaseRequest | Many-to-one |
PurchaseRequest | items | PurchaseRequestItem | One-to-many |
Inverse relationships
Section titled “Inverse relationships”A relationship pair connects the same records in both directions. The many-to-one relationship identifies the parent record from the related record, while the inverse one-to-many relationship exposes the collection from the parent record.
For a header-detail structure, define the many-to-one relationship on the detail entity and then connect the corresponding one-to-many relationship on the header entity as its inverse. For example:
PurchaseRequestItem.requestidentifies the purchase request that owns an item.PurchaseRequest.itemsexposes the items related to a purchase request.
Inverse relationships are also useful outside a traditional header-detail structure. A Quotation can reference the PurchaseRequest it belongs to through purchaseRequest, while the purchase request exposes its quotations through quotations.
For the editor fields and configuration sequence, see Transactional Entity Editor.
Header-detail structures
Section titled “Header-detail structures”Transactional entities commonly use a header-detail pattern:
- The header entity represents the main business record, such as a purchase request or quotation.
- The detail entity represents a related line item, such as a purchase request item or quotation item.
One-to-many relationships are not limited to line items. Use them whenever one record needs to expose a collection of related records, such as the quotations received for a purchase request.
Access related records
Section titled “Access related records”The relationship name becomes the property used to access the related data. A many-to-one relationship exposes one related record, while a one-to-many relationship exposes a collection.
For example:
item.requestrequest.itemsrequest.quotationsWhen a screen variable contains a PurchaseRequest, its relationships can appear as nested screen data:
screen.request.itemsscreen.request.quotationsBecause items and quotations are one-to-many relationships, Lowgile exposes them as arrays. Screens can render these collections with a Data Table or For Loop and can add related objects to them through screen actions.
For collection rendering and loop-scoped bindings, see Rendering Collections on Screens.
Relationships and properties
Section titled “Relationships and properties”Use a property to store a value that belongs directly to one record, such as a description, quantity, or comment. Use a relationship when one entity needs to reference or expose records defined by another entity.
Relationship configuration also controls details such as the target entity, relationship direction, ID property name, inverse relationship, and whether the database constraint is enforced. These are editor settings rather than data-model concepts; see Transactional Entity Editor for their configuration.