Previous Topic

Book Contents

Book Index

Next Topic

N to M Relations

Collections provide full support for N:M relations. As an example of this relationship we might give the one between systems and their cost centers (a TRL collection). There, a cost-center may obviously handle a number of systems and also the other way round, one system can belong to various cost-centers.

By support we mean that when you browse through a collection representing a N:M, relation it is automatically detected and subsequently you transparently see and work with the target objects that the relation actually points to, instead of the auxiliary link objects physically held by the collection and which provide only a little or no information, which might be of use to the user.

For example, system x cost center is a “N:M” relation and therefore is implemented through a link object, since the database cannot store such relations directly. In our case, the link looks as follows: System – SysCostCenters – CostCenter, where SysCostcenters is a collection of link objects.

To check if the collection holds links to target objects:

ApiBOCollection.isLinkCollection()

To learn if the collection is defined by an N:M relation:

ApiBOCollection.isN2MCollection()

Returns TRUE if the collection represents a N:M relation. Otherwise returns FALSE.

If isLinkCollection is true then also isN2MCollection is true, but not vice versa.

You might want to retrieve the link object, for example, to learn about the validity of the object. To do so, call

ApiBOCollection.linkItem(int)

Returns a link object from a N:M relation by its order number (for example, a “TRL” collection). Normally, the link object that may carry the time information is encapsulated and cannot be seen from outside.

Obtaining the link object is crucial in the time-related usage when it enables you to find out the information about the validity of the link. See Time Related Links (TRLs) for a detailed information about Time Related Links.

In some cases, the collection definition can be customized so that the item() method does not return the target object but the link object instead, such is the case of the collections retrieved from ApiGuiViewOfToMany. To ensure that you get the link object, use

ApiBOCollection.targetItem()

Returns the target object defined by a given order number.

See Also

Collections

Creating Collections

Time-related Feature

Listing Collections

Adding Objects to Collections

Appending BOCollections to Collections

Merging BOCollections

Removing Objects from a Collection

Sorting Collections