Reputation: 3305
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?
Upvotes: 36
Views: 65222
Reputation: 29
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)
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.
Upvotes: 1
Reputation: 494
ER diagram:
Class diagram:
ORM(object relation mapping):
Upvotes: 10
Reputation: 31
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!
Upvotes: 3
Reputation: 61
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!
Upvotes: 6
Reputation: 1370
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.
Upvotes: 28