Associations

Associations are a conceptual feature to associate domain terms in a modeling system.

Associations are based on semantic of PK/FK links in relation data model, but in Paml associations are just conceptual feature that allow specifying how domain terms are associated each other with corresponding arity. Concrete implementation of an association is specified in transformations, so the association can be translated into PK/FK relationship in relation DB or object graph with references via properties like in C#.

Associations are a Paml language feature, like values, objects or abstractions. Associations are not mapped to object data, collaborators or value items, so objects consist of state, collaborators and associations.

Associations define association properties, like navigation properties in Entity Framework.

An association can have an optional name, so a transformation can be applied to it. The applied transformations can assign filtering to association properties, produce indexes and/or constraint etc.

As a particular case, associations can be used to declare a domain scheme like DbContext in Entity Framework.

Associations can connect different kinds of Paml elements, that’s objects can be associated with values, or values can be associated with abstractions. But in essence, associations are though data model mechanism, so any Paml elements are treated as data/values.

In Paml source code, association properties are displayed in different styling/colors than any other elements like object data/collaborators or value items, to highlight that associations have special semantics.

abstraction Alonzo . Banking . Account
{
data Number;
message Withdraw ( val amount : decimal );
}
subject Alonzo . Banking . Client
{
data Name : string;
}
value Alonzo . Banking . Transfer
{
Amount : decimal;
}
association Association name is optional, but required if a transformation is applied.
{
One-to-many association
Alonzo . Banking . Client . Accounts (*) - (1) Alonzo . Banking . Account . Owner
}
association Transfer.Source
{
Alonzo . Banking . Transfer . Source (1) - (*) Alonzo . Banking . Account . SourcingTransfers
}
association Transfer.Target
{
Alonzo . Banking . Transfer . Target (1) - (*) Alonzo . Banking . Account . TargetingTransfers
}
{
obj client : Alonzo . Banking . Client ;
client.Accounts (account)
forEach {
print ( account . Number ) };
client.Accounts (account)
forEach {
account->Withdraw (amount : 100.75) };
client.Accounts (account)
selectMany {
account.SourcingTransfers } (transfer)
forEach {
print ( transfer ) };
}
{
obj account : Alonzo . Banking . Account ;
print ( account . Owner . Name ) ;
val transfer : Alonzo . Banking . Transfer ;
print ( transfer . Amount ) ;
print ( transfer . Source ) ;
print ( transfer . Target ) ;
}

Write a comment

Comments: 0

Pallada project, Copyright © 2015 - 2021.

For any mentions and citations of the site materials, a link to the Pallada project site is obligatory.