O/R Mapping
Mac OS X
Tips and Tricks
UML Diagrams
VP Suite
Change Log

Using ORM Diagram

An ORM diagram is used to show the mapping between the ORM-Persistable class and its corresponding entity. VP’s products allow you to name the ORM-Persistable class and its corresponding entity differently, and also the attributes and columns as well. In some cases, you may find it difficult to identify the mappings not only between the ORM-Persistable classes and the corresponding entities, but also between the attributes and columns.

Taking the advantage of ORM diagram, the mappings between ORM-Persistable classes and entities, and between attributes and columns can be clearly identified. Let us learn the usage of the ORM diagram.

Creating ORM Diagram

You can create an ORM diagram by one of the three methods:

  1. On the menu, select File > New Diagram > Others > ORM Diagram.
  2. On the Diagram Navigator, right-click ORM Diagram > Create ORM Diagram.

  3. On the toolbar, click the New ORM Diagram.

Creating ORM-Persistable Class and Mapping Entity

After created a new ORM diagram, you are allowed to create an ORM-Persistable class and its mapping entity on the ORM diagram.

Creating ORM-Persistable Class

To create an ORM-Persistable class on ORM diagram:

  1. On the diagram toolbar, click Class icon.

  2. Click anywhere on the diagram to create an ORM-Persistable class.

  3. Enter Student as the name of the ORM-Persistable class.

  4. Mouse over the Student class, drag the One-to-One Association → Class resource to the diagram to create another ORM-Persistable with a one-to-one directional association.

  5. Enter Profile to the name of the newly created class.

Creating Mapping Entity

To create the mapping entity of the ORM-Persistable class:

  1. Mouse over the Student class, click and drag the Class-Entity Mapping → Entity resource to the diagram.

    The mapping entity, Student is created automatically.

  2. Create the mapping entity of Profile class by using the Class-Entity Mapping → Entity resource.

Note: You can create the Entity and the mapping class using the same approach of Creating ORM-Persistable Class and Creating Mapping Entity by using the Entity icon on the diagram toolbar and the Class-Entity Mapping → Class resource.

Switching the View of Mapping

ORM diagram provides two views of mapping, including the mapping between ORM-Persistable class and entity (called Class Mapping), and the mapping between attributes and columns (called Attribute Mapping).

To change the view of mapping, right-click on the ORM-Diagram, select the desired view from the sub-menu of View.

Modifying ORM-Persistable Class

You can modify the ORM-Persistable class such as renaming the class name and adding attributes to the class.
Let us add three attributes, including StudentID, Name and CourseCode to the Student class.

  1. Right-click the Student class, select Add > Attribute from the pop-up menu.

    Note: You can add the attribute by using the shortcut, Alt + Shift + A.
  2. Enter StudentID : String to the attribute.

  3. Repeat steps 1 and 2 to add the other two attributes to the Student class as shown below.

Modifying Entity

You can modify the entity such as renaming the entity name and adding columns to the entity.

Let us rename the Profile entity to StudentProfile, and add the DateOfBirth, YearOfEnrollment as the columns of the entity.

  1. Double-click the Profile entity, enter StudentProfile to rename the entity.

    Note: You can edit the entity name by selecint the entity and pressing the F2 button.
  2. Right-click the StudentProfileentity, select New Column from the pop-up menu.

    Note: You can add the column by using the shortcut, Alt + Shift + C.
  3. Enter DateOfBirth : date to define the column.

  4. Repeat steps 2 and 3 to add the YearOfEnrollment column as shown below.

Synchronizing Attributes and Columns

To synchronize the attributes added to ORM-Persistable class to the mapping entity:

  1. On the ORM diagram, hold down the right-mouse button, move the mouse from left to right to form the gesture which is indicated by the blue path.

    The attributes are synchronized to the mapping entity automatically.

To synchronize the columns added to entity to the mapping ORM-Persistable class:

  1. On the ORM diagram, hold down the right-mouse button, move the mouse from right to left to form the gesture.

    The columns are synchronized to the mapping class.

  2. Right-click the ORM diagram, select View > Attribute Mapping from the pop-up menu to view the mapping in detail.

    After changing the view of the ORM diagram from Class Mapping to Attribute Mapping, the ORM diagram shows as below.

Related Articles


Last modified: 2006/03/21 13:12
Home | Recent Topics | Highlights | UML Diagrams | Tips and Tricks | Object-Relational Mapping
visual-paradigm.com Home | Training Center | UML Center | VP Gallery | Discussion Forum | UML Open Directory