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.
    using_orm_diagram-1.jpg

  3. On the toolbar, click the New ORM Diagram.
    using_orm_diagram-2.jpg

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.
    using_orm_diagram-3.jpg

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

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

  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.
    using_orm_diagram-6.jpg

  5. Enter Profile to the name of the newly created class.
    using_orm_diagram-7.jpg

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.
    using_orm_diagram-8.jpg

    The mapping entity, Student is created automatically.
    using_orm_diagram-9.jpg

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

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.
using_orm_diagram-11.jpg

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.
    using_orm_diagram-12.jpg

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

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

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.
    using_orm_diagram-15.jpg

    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.
    using_orm_diagram-16.jpg

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

  4. Repeat steps 2 and 3 to add the YearOfEnrollment column as shown below.
    using_orm_diagram-18.jpg

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.
    using_orm_diagram-19.jpg

    The attributes are synchronized to the mapping entity automatically.
    using_orm_diagram-20.jpg

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.
    using_orm_diagram-21.jpg

    The columns are synchronized to the mapping class.
    using_orm_diagram-22.jpg

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

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

Related Articles

Resources

 
 
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