I'm currently working on a project in which we're required to define a Entity Relationship Diagram and a UML Class Diagram from a set system.

I've successfully managed to define the ERD. It required me to break down information from a specification and form them into entities and then define a relationship between the entities to represent the system.

Now that I've done that I'm now onto the UML Class Diagram, but the only issue is I have no idea how to incorporate what I've defined inside my ERD into a UML Class Diagram as I've been told the structure between both diagrams are quite different.

  • Do entities from the ERD in a sense serve as a class in the UML?
  • Do the attributes from the entities in the ERD form the attributes in the classes?
  • How can you easily define what attributes and methods you make public, private, and protected?

I understand a lot of the basics of UML and ERD on their own, but to take an entity relationship diagram and appropriately incorporate it into a UML is something i'm quite lost on where to start with.

Any tips or advice would be greatly appreciated.

2 Answers 2


UML class diagrams can be seen - roughly - as a superset of ERDs. UML class diagram notation is younger, surely made with the intention to incorporate or replace older notations like ERD, and it contains additional elements like inheritance, methods, or private attributes which are not part of ER modeling. ERDs were made strictly with data modeling for relational databases in mind, UML was designed for a broader usage, primary class modeling, but not exclusively for this.

So it is not astonishing you can take any ERD and transform it into an UML class diagram by the obvious translation "entity->class", "attribute->attribute", "relationship->relationship". The visibility of the attributes should all map to "public", since ERDs doesn't have a concept of private attributes (and obviously not of protected ones, since ERD also lacks the inheritance concept).

Googling for "translate ERD to UML" found me this scientific paper on mapping between UML and ER models, I think there you find much more about the gory details.

Another aspect here is when you want your graphical models to match exactly an implementation in code. Object-relational mappers (ORM) like MS Entity framework or Hibernate have typically specific rules how to generate classes in a programming language from a database schema. If you want your class model to match exactly the generated classes of an ORM, the best way is probably to map the ERD into a physical DB schema first, let the code generator of your favorite ORM generate classes in code, and then try some UML reverse engineering tool to create a class diagram from that code.

  • One question though, when you say the attributes of the ERD turn into the attributes of the UML Class, does that include foreign keys and linked entities between MANY to MANY entities? Nov 25, 2017 at 11:51
  • @HenryGreen: UML gives you some freedom how you do it, there is no strict rule if you need to model foreign key attributes explicitly, or not. However, by giving the associations role names, and having a mapping rule from those role names to foreign key names, you can avoid the need for modeling foreign keys as attributes.
    – Doc Brown
    Nov 25, 2017 at 12:42

@Henry-Green Adding to @Doc-Brown's answer, data-centric classes map to model components in a Model View Controller architecture pattern.

Regarding your question about what to make public vs. private or protected, a general programming best practice is to follow the Principle of Least Privilege.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.