Architecting and designing > UML 2.0 Lite > Object/relational integration > Mapping a data model to a Class diagram > Mapping a data model to a Class diagram, Specifics
  
Mapping a data model to a Class diagram, Specifics
You can automatically map a logical ER data model to a UML class model, enabling you to capture data in your legacy system and take the first step toward redesign using object-oriented methods and UML.
Models are mapped to UML packages
The Model that the ER diagram is contained in is mapped to a UML package of the same name.
If Set Stereotypes is selected in the Convert ER - OO dialog when generating, then a stereotype of <<logicalDataModel>> is provided for packages mapped from UML packages.
Entities are mapped to classes
Each entity is mapped to a class of the same name.
Entity attributes are mapped to attributes of the corresponding class.
Entity Description is mapped to Class Description.
Classes created have their Persistence property set to Persistent. This property is located in the General tab of a class definition.
If Set Stereotypes is selected in the Convert ER - OO dialog when generating, then a stereotype of <<logicalDataModel>> is provided for packages mapped from UML packages.
Entity attributes are mapped to class attributes
Entity attributes are mapped over to class attributes of the corresponding class, if they do not already exist.
The class attribute is given the same name as the entity attribute, and the data element is added as a source property of the class attribute.
The new class attribute type is determined through the type translations specific for each language, as listed below:
Java type mapping to from data element types
C++ type mapping to from data element types
Visual Basic type mapping to from data element types
CORBA type mapping to from data element types
Entity Attribute Description is mapped to Class Attribute Description.
If Set Stereotypes is selected in the Convert ER - OO dialog when generating, then:
A stereotype of <<PK>> is provided for class attributes mapped from entity attributes designated as primary keys in the data model.
A stereotype of <<FK>> is provided for class attributes mapped from entity attributes recognized as foreign keys in the data model.
A stereotype of <<PFK>> is provided for class attributes mapped from entity attributes that are part of a candidate key for an entity and part of a foreign key for another entity.
Entity relationships are mapped to class associations
Identifying relationships
Identifying Relationship is mapped to Association Between Corresponding Classes.
Entity Relationship Description is mapped to Class Association Description.
Cardinality of relationship is mapped to multiplicity of Class Association.
Attribute that is a Foreign Key in an Identifying Relationship is mapped to a new attribute with a stereotype of <<PFK>> (see example below).
If Set Stereotypes is selected in the Convert ER - OO dialog when generating, the association is set so that a uni-directional arrow appears: Navigable for that end of the association is on. Also for the Class Diagram, the Diagram property Navigation Presentation Mode is set to No Bidirectional (see example below).
Example
Foreign Key (attribute “a” in Entity_3 below) in an Identifying Relationship ...
This graphic is described in the surrounding text.
... is mapped to a class attribute with stereotype <<PFK>>:
This graphic is described in the surrounding text.
The association is set so that a uni-directional arrow appears: the Navigable property for that end of the association is selected. Also for the Class Diagram, the Diagram property Navigation Presentation Mode is set to No Bidirectional Arrows, so that the navigational arrow is displayed.
Non-Identifying Relationships
Non-Identifying Relationship is mapped to Association Between Corresponding Classes
Entity Relationship Description is mapped to Class Association Description.
Cardinality of relationship is mapped to multiplicity of Class Association.
Attribute that is a Foreign Key is mapped to a Class Attribute with a stereotype of <<FK>> (see example below).
If Set Navigability is selected in the Convert ER - OO dialog when generating, the association is set so that a uni-directional arrow appears; the Navigable property for that end of the association is selected. Also for the Class Diagram, the Diagram property Navigation Presentation Mode is set to No Bidirectional.
Example
Foreign Key (attribute 'a' in Entity_5 below) in a Non-Identifying Relationship ...
This graphic is described in the surrounding text.
... is mapped to a class attribute with stereotype <<FK>>:
This graphic is described in the surrounding text.
Non-Specific Relationships:
Non-Specify Relationship Between Two Entities is mapped to Association Between Corresponding Classes
Entity Relationship Description is mapped to Class Association Description.
Cardinality of relationship is mapped to multiplicity of Class Association.
ER Diagram Super-Sub Relationships Are Mapped to UML Inheritance
Super-sub type relationship in ER Diagram is mapped to Inheritance relationship in UML Class diagram
Options for generation
When you select to map an ER Diagram to a UML Class diagram (select Dictionary, Convert to Class Diagram), you can specify mapping options.
Set Stereotypes: maps ER artifacts to appropriate UML stereotypes as specified above.
Set Navigability: sets Navigability property of associations on UML class diagram as appropriate, as specified in relationship mappings above.
See also
Procedure for mapping a logical data model to a class model
Mapping a data model to a Class diagram