How to Generate Class Diagram from ERD?

Visual Paradigm supports generating class diagrams from ER diagrams (entity relationship diagram). Entities and relationships are mapped with classes and associations accordingly. This tutorial teaches generating class diagrams from entity relationships diagrams and how to synchronize description between classes and entities.

October 30, 2009
Views: 265,875
PDF Download

To generate class diagrams from entity relationship diagrams:

  1. First, open the Project Browser by selecting View > Project Browser from the toolbar.
    open project browser
  2. Click the New Model button to create a new model.
    new model
  3. Enter the name as "Entity Model."
    input eame in model specification
  4. Now, let's create an entity relationship diagram under Entity Model. Right-click on the Entity Model and select Sub Diagrams > New Diagram....
    create diagram
  5. In the New Diagram popup window, select Database Modeling > Entity Relationship Diagram. Click OK to confirm.
    create entity relationship diagram
  6. Develop the following entity relationship diagram.
    device support history er diagram
  7. Repeat the above steps to create the following entity relationship diagram under Entity Model.
    device puurchase er diagram
  8. Once the entity relationship diagrams are ready, we can then generate class diagrams from our entity relationship model. Select Tools > Hibernate > Synchronize to Class Diagram from the toolbar.
    synchronize to class diagram
  9. The Synchronize from Entity Relationship Diagram to Class Diagram dialog will be shown. The entity relationship diagrams in your project are shown on the left-hand side of the table, and the target class diagram is shown on the right-hand side.
    er diagram to uml class diagram mapping dialog box
  10. Click on the entity relationship diagram cell, and the preview will be shown.
    preview erd diagram
  11. You can name the target class diagram directly in the class diagram cell, or you can synchronize to an existing class diagram (if any).
    assign meaningful name to uml class diagram
  12. Press OK to proceed.
  13. Now the Synchronize to Class Diagram dialog will show up. The mapping between entity name and class name, as well as the column name and attribute name, will be listed in the dialog. Let's change the name of the User class to Customer and change the attribute name from firstname to firstName.
    entity column to class attribute mapping table
  14. We can specify the target for storing the output class diagram. Select Specify... in the Target Parent combo box.
    selecting target model
  15. Select the root node in the tree and press the New Model button. Name the model Class Model.
    create class model
  16. Press OK to proceed.
  17. Now the class diagrams are being generated.
    generated uml class diagrams
  18. Let's try to modify the description of the class PriorityType.
    modigy priority type class description
  19. You can synchronize the description from the class model to the associated entity model by right-clicking on the diagram and selecting Utilities > Synchronize Class Description to ERD.
    synchronize class documentation to ER diagram
  20. The Class Description to ERD dialog will list class models that contain different descriptions from the entity model.
  21. Click on the entity PriorityType in the list, and the differences in descriptions between the class and entity model will be shown.
    synchronize class documentation dialog box
  22. Select the checkbox under the Synchronize column to specify the model you would like to synchronize their descriptions.
    check synchronize classes and entities
  23. By selecting the Synchronize members checkbox, the descriptions of the class attribute and entity column will also be synchronized.
    check synchronize member checkbox
  24. Uncheck the Hide equals checkbox, and all classes/entities will be listed, even if their descriptions are the same.