R802 - modelint/shlaer-mellor-metamodel GitHub Wiki

R802 / Generalization

Non Scalar Flow is an Instance Flow or Relation Flow

All non scalar values are tabular, i.e. relations. Relational theory defines a relation as having a header and body component. The header is a set of attribute:type pairs. In our metamodel we just call these attributes, as the type association is implied. The body component is a set of tuples such that each tuple carries one value for each attribute in the header. When we use the term tabular, we are referring to this header-body structure.

All attributes are associated with scalar types in our metamodel. In other words, a value found at a row-column intersection will always be a scalar value. From a relational theory standpoint, there is no need for this limitation, but it is reasonable in our metamodel domain.

An Instance Flow conveys instance reference values. These are tabular with the restriction that the header is specified by an Identifier.

A Relation Flow is defined by a non-identifier header. These are useful when performing a computation or evaulation based on a mix of attributes taken from a single Class, multiple Classes, or intermediate computed values.

Note that a header is defined above as a set of attributes. This includes the empty set. Since an Identifier consists of at lease one Attribute, the header of an Instance Flow must consist of at least one Attribute.

Relation vs. Instance Flows

There is no such limitation on a Relation Flow. Consider the following relation operation in Scrall:

any flying aircraft #= Aircraft( Altitude > local airport.elevation ).()

The right hand side of this expression selects from the Aircraft class population based on elevation criteria, but projects over an empty set of attributes .(). The result is assigned as a Relation Flow using the #= table assignment operator. The reasoning being that we just want to know if there are any instances or not. The attribute values don't matter.

If one or multiple instances meet the criteria, the resulting value will be a relation with zero attributes and one tuple. If no instances meet the criteria, the resulting value will have zero tuples. This is effectively a relational boolean with the first case corresponding to true.

Using an Instance Flow instead, we would do this in Scrall:

flying aircraft ..= Aircraft( Altitude > local airport.elevation )

Here we use the Instance Flow assignment operator. There is no need to project on the attributes of Aircraft, since this kind of assigment will use an Identifier of the Class. Assuming that is ID typed Tail Number, we can visualize the resulting instance references as constituting a table with a single attribute header ID and zero or more tuples.

The choice of assigning a Table or Instance Flow is based on the computation being performed. If you are nesting a variety of computations and evaluations and doing come table magic, a Relation Flow assignment might be a better choice. But if all you want to do is obtain the set of flying aircraft, the Instance Flow approach is preferrable.