Constrained Objects
EXPRESS uses constraints to ensure that data conforms to the intended semantics of the information model. This lesson covers the constraint mechanisms available in the language.
Local Constraints
Global Constraints
Global rules can span multiple entities and reference multiple instances:
RULE unique_product_ids FOR (product);
LOCAL
ids : SET OF STRING := [];
END_LOCAL;
REPEAT i := 1 TO SIZEOF(QUERY(p <* product | TRUE));
IF p[i].id IN ids THEN
RETURN(FALSE);
END_IF;
ids := ids + p[i].id;
END_REPEAT;
RETURN(TRUE);
END_RULE;Derived Attributes
Attributes can be computed from other attributes:
ENTITY board;
width : REAL;
height : REAL;
DERIVE
area : REAL := width * height;
END_ENTITY;