The concept is especially useful for modeling Object-Relational Mapping (ORM) – UML Class Diagram can be used for the application object model and Entity-Relationship Diagram (ERD) for the database model. The mapping definition allows you to share names between these diagrams and their elements. The names may be transformed using the pre-defined transformation functions.
Mapping definitions can be used in various scenarios:
- Object-relational mapping (ORM)
- Mapping an old model to a new model
- Mapping a base model to other models for various domain areas
Create Mapping Definition
If you want to create a new mapping definition, you can do it from:
- Ribbon: Insert tab / Project group / Add Mapping Definition
- Menu: Project / Add Mapping Definition
A new mapping definition will be added to the active project folder.
Create a Diagram Copy with Mapping to Its Original
If you want to create a complete copy of a diagram and create a mapping definition between the original diagram and its copy, you can use the following action: Ribbon / Diagram tab / Editing group / Create Diagram with Mapping
The action has these outputs:
- A copy of the active diagram. The diagram copy contains copies of all original elements. The models of the elements are not shared.
- A mapping definition with mappings from all original elements and fields to all copied elements and their fields. The name transformations for all mappings are set to 'Same'.
Editing Mapping Definition
The Mapping definition editor allows you to define the main diagram you want to map from and another main diagram you want to map to. The elements from these diagrams will be automatically offered in the combo boxes in the editor. However, you can also map from/to elements from other diagrams. So, the mapping definition is not restricted only to two diagrams.
The Mapping Definition editor contains these buttons:
Add Element – adds an element from the current project to the mapping. After adding the element, other elements can be mapped to it.
Add New Rule for Field – duplicates the selected field mapping rule. You can edit the duplicated rule to map the selected source field to multiple target fields. (This is useful if the information from the field is expressed in two separate fields in the target mapped element.)
Delete – offers two options what to delete:
Delete Element – deletes the whole mapping definition for the selected element.
Delete Rule – deletes only the selected field mapping rule.
Map to Element – opens a picker dialog in which you can choose any project element which will be the selected element mapped to.
Apply – applies all mapping rules from the mapping definition. The name transformation will be applied to source elements and their fields and the transformed names will be set to the target mapped elements.
The Mapping Definition editor contains two tabs – Mapping and Elements.
The Elements tab provides a list of all elements that are used as source elements in the mapping (From Elements) and a list of all elements that are used as target elements in the mapping (To Elements).
The Mapping tab contains a grid with the following columns:
- Order Index
- Rule Name – a user-defined name for the mapping rule
- Status – allows you to choose a status of the mapping rule from these options:
- Mapping Condition – user-defined condition for the mapping. For documentation and source code generation purposes only. It is not handled anyhow within the project processing so far.
- From Element – a source element
- From Field – a field of the source element
- Data Type (From)
- Nullability (From)
- Name Transformation – offers various transformation rules that allow the program to fill the names of mapped elements automatically by the names. You can choose one of these transformations:
- Camel Case
- Pascal Case
- Lower Case
- Upper Case
- To Element – a target element that the source element (From Element) is mapped to.
- To Field – a target field that the field of the source element (From Field) is mapped to.
- Data Type (To)
- Nullability (To)
- Transformation Function – custom transformation function. For documentation and source code generation purposes only. It is not handled anyhow within the project processing so far.
- Note – user notes to the mapping role