Difference between ER diagram and Class diagram
Asked Answered
R

5

36

I have been given a description and need to draw ER diagram and Class diagram for the description.

Now I am having issue with understanding the differences between these 2 diagrams.
When I draw the diagrams entities of ER diagram becomes classes. I am not sure whether I am in right track.

Please explain me what is the difference and similarities of these two?

Rill answered 11/6, 2013 at 17:43 Comment(2)
Check my similiar answer #16449679Underneath
IMHO, you'll learn a great deal from this answer https://mcmap.net/q/428000/-differences-between-a-conceptual-uml-class-diagram-and-an-erd to a related question.Horal
S
28

From DifferenceBetween.com:

ER diagrams represent the abstract representation of the data model, while class diagrams represent the static structure and behavior of the proposed system. Main building blocks of ER diagrams are entities, relationships and attributes but the main building blocks of class diagrams are classes, relationships and attributes. Class diagram are more likely to map in to real-world objects, while ER diagrams most often map in to the tables in the database. Usually, relationships found in ER diagrams are more difficult to understand for humans than relationships in class diagrams.

Skyros answered 5/11, 2013 at 4:59 Comment(0)
S
10

ER diagram:

  • what is contained in the database like the table, relationship, primary key, foreign key, what is a weak entity,

Class diagram:

  • what is contained in class like attributes, types of attributes, method, the return type of methods, method's parameter, a relationship of a class(inheritance, aggregation etc.). plus there are also about an interface, abstract class.

ORM(object relation mapping):

  • there are ORM tools available in any language.
  • where you have to create only an ER diagram from that we have to create only class any based on a class it will automatically create a database.
  • so we don't need to create a class diagram.
Seine answered 7/8, 2018 at 7:34 Comment(0)
N
6

When you think of Class Diagrams, you are thinking about the organization of behaviors or simply functions. In example, calculate costs function using state tax information. Then you may have different classes representing different calculation functions (See strategy pattern from GoF design patterns).

When you think about an ER diagram, you are thinking about the rules around the existence and relationship of data that will be stored. A user account must have a username and a bank account can have only one primary user account.

To sum up, with class diagrams you think about the organization of behaviors/functions, while with ER diagrams you think about the organization of data assets. The two definitely relate when building an entire application, but have two different perspectives in the design of the application being built.

Hope that explanation helps!

Naze answered 26/1, 2019 at 22:19 Comment(0)
C
3

There are many ways to tell the difference between ERD and Class diagram.

For instance, ERD, otherwise known as Entity Relationship Diagram, only portrays systemic features. On the other hand, Class Diagram displays the most vital sections of a system, the systemic and behavioural features.

In Unified Modelling Language, UML, features are shown as unencrypted text in ‘the class rectangle box’. However, in an Entity Relationship Diagram, the features are ‘oval linked to the entity type’.

ER Diagram has relationships which are more complex than Class diagram and are more complicated to be deciphered by humans. ER Diagram contrasts to Class diagram since it ‘maps into tables in database’ whereas Class diagram maps into actual objects.

Another distinction is that Class diagram has some relationships which are not implied and modelled in Entity Relationship Diagram.

The main segments of Entity Relationship Diagrams consist of entities, relationships and attributes whilst classes, relationships and attributes are the segments of Class Diagrams.

Hope this helps anyone!

Cullis answered 11/4, 2019 at 21:51 Comment(0)
W
1

one of the differences between ERD and class diagram is in ERD we can define an intermediate entity, for example, we want to define a "book shopping" website. (like the below image) enter image description here

See we should define "Warehouse_Book" for the "ERD diagram" and implement the DB structure but in "class diagram we don't have any class like this.

Willmert answered 18/12, 2022 at 11:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.