One field association with multiple tables


I am very new to Cuba. My question would be is it possible to associate a field with multiple tables depending on the value in some other field, for example:

Suppose we have a table “Sales Order Line” and I want it to hold both item entries and also entries posted directly to General ledger. So I might have the following columns

Document No - key to Sales Order
Line No. - Sales Order Line No.
Type - Sales Order Line Type, possible values “Item”, "G/L Account"
No. - Item or "G/L Account No."
Unit Price

So I want when Type = Item, link the line to Item table, when it is G/L Account, then to “G/L Account” table.

Such approach is widely used in Microsoft Dynamics NAV.
Is it possible? If not, what could be the best approach to deal with that?

Many thanks


It is possible IF the LineItem class is using inheritance, with a discriminator field.

So if the superclass is LineItem class, and have two descendant: OrderLineItem and GeneralLedgerLineItem and the inheritance is setup for SINGLE_TABLE and You use a discriminator field to separete those two classes, then You can do it.


For entity inheritance, see this sample application:

It is also available on the Samples tab in Studio.

1 Like