The derivation in the data model

From Wiki

Jump to: navigation, search

The data model can be enriched with many informtion that can be derived from other elements in the model. This kind of information is called "derived data". In WebRatio the derivation is expressed through WebML OQL derivation queries. In the database all derived information are installed as views. In order to specify a derived information you have to use the Derivation Wizard. The wizard is available clicking on the button next to the "Derivation" property in the General tab of the Properties View after you added the element you want to derive in the data model. In a data model you can derive:

  1. Entities. A derived entity is an abstract concepts that represent a subclass of objects having a specific property. Usually a derived entoty filters the records of another entity (called master entity) using some criteria. In the following figure there is an example. The derived entity "Italian Artist" groups only the records of the entity "Artist" which as "Italian" as nationality. The derived entity has all the attributes of the master entity and also shares all the relationships outgoing from the master entity. You can also add attributes and relationships to the derived entity, but all these information belong only to the derived entity and not to the master entity.
  2. Attributes. A derived attributes is an abstract concepts that represent a specific entity property. In this case the value of the property can be inferred by other attributes (either of the same entity or other entities) or by relationships. There are different ways to derive an attribute:
    • Constant attribute. It defines an entity property that as a constant value.
    • Imported attribute. It defines an entity property copying the value from another attribute of a different entity. You can copy values only from attributes belonging to entities connected to the interested one with a 1-N relationship. In particular the 1 cardinality has to belong to the entity on which you are specifying the derived attribute.
    • Calculated attribute. It defines an entity property through a calculation using other attributes or through an aggregation of other properties. The available aggregation operators are: sum, avg, min, max.
    • Manually mapped attribute. This type of attribute is used when the other types does not fit you purposes. It happens that the Derivation Wizard is not able to construct the SQL view exactly as you want. In these cases you can manually write the SQL code and create the view on the database and then map that view on an attribute. This is the type of attribute you have to choose in order to perform this operation.

Here is an example of data model using derived attributes.

  1. Relationships. A derived relationship is an abstract concept representing an aggregation between entities which can be definied starting from an existing relationship or specifying conditions on the envolved entities. So there are three ways to derive relationships:
    • By restriction. In this case the derived relationship is definied specifying some conditions of an existing relationship. The connected records are a subset of the master relationship.
    • By concatenation. The derived relationship is a composition of existing relationships.
    • New relationship. It is defined specifying conditions on the entities the new relationship is going to connect.

All derived elements can be used in the Web model as any other element of the data model.

Personal tools