Calculated attributes
|
Copyright 2008-2010 ManyDesigns srl. All rights reserved.
PurposeWhile most attributes are entered directly by the users through create/edit forms, some other attributes can be more conveniently calculated automatically by the system. In database terms, this operation is a de-normalization: certain attributes become functionally dependent from others.Calculated attributes are convenient for usability, performance and to define constraints. The modeler can make an attribute calculated by defining a formula, which instructs ManyDesigns Portofino about which operands and operators to use in the calculation. To make an attribute calculated go to its details page and click on the Formula button. Calculated attributes are also the foundation for constraints. OperandsConstant operands:
Scalar vs. vectorCertain operands (constants, attributes on the same class and attributes on other classes related through a many-to-one relationship) are scalar. Their value are of basic type: a number, a string, a boolean.Other operands, namely attributes on other classes related though a one-to-many relationship, are vectors. Their value is a vector of a basic type: a vector of numbers, a vector of strings, a vector of booleans. Vector operands are used with aggregation operators (see below). OperatorsArithmetic operators:
Formulas syntaxFormulas follow the natural syntax of math formulas and of many programming languages. Binary operators (+, -, *, /, etc.) follow the same associativity rules as in the C language.You can use parentheses to explicitly specify associativity or for readability. Operands (A1, A2, etc.) are not case-sensitive (can be typed as a1, a2, etc). Operators (and, or, len, match, etc.) must be entered in lower case. Calculation rulesIf you create a new formula or change an existing one, all the attribute's values in the database are (re)calculated. This sometimes confuses new users, who expect the formula to be applied only to new objects. The rule is that formulas are applied to all objects: existing ones and new ones. So beware: old values are overwritten.A calculated attribute can be defined in terms of other calculated attributes, which in turn can be defined in terms of other calculated attributes. This effectively creates a graph of dependencies between the attributes of the model. ManyDesigns Portofino finds out and applies the correct order of calculation. This "propagation" is automatic so you don't have to worry about it. No circular definitions (an attribute defined in terms of itself, either directly or indirectly through other calculated attributes) are allowed. Previous: Workflows
Next: Constraints |