Skip to content

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.

Lowgile supports two relationship types:

  • Many-to-one: Multiple records relate to one target record. For example, multiple PurchaseRequestItem records can reference one PurchaseRequest through a relationship named request.
  • One-to-many: One record relates to multiple target records. For example, one PurchaseRequest can expose its related PurchaseRequestItem records through a relationship named items.

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 entityRelationshipTarget entityType
PurchaseRequestItemrequestPurchaseRequestMany-to-one
PurchaseRequestitemsPurchaseRequestItemOne-to-many

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.request identifies the purchase request that owns an item.
  • PurchaseRequest.items exposes 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.

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.

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.request
request.items
request.quotations

When a screen variable contains a PurchaseRequest, its relationships can appear as nested screen data:

screen.request.items
screen.request.quotations

Because 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.

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.