If you studied system design and analysis during your tertiary degree, chances are high that you came across Unified Modelling Language (UML). So you might feel slightly surprised to see the Entity-Relationship Diagram (ERD) and wonder why they are calling it ERD despite it looking so similar to UML. 

UML is a more general-purpose modeling language; on the other hand, ERD is typically used to model the structure of a database. UML is used for various purposes including, but not limited to, visualizing, specifying, and documenting the artifacts of a software system, use case diagrams, class diagrams, etc.

However, the concepts are not far apart. So, you can represent ERD using a UML class diagram. Here is a brief explanation of how to map ERD concepts using UML,

  1. Entities
    1. In ERD, entities represent tables in a database. In UML, these will be called class diagrams.
    2. Entity attributes in ERD are the same as the property of the class in UML. Therefore, you can put entity attributes as property in UML.
  2. Relationships
    1. While you have relationships between entities in ERD, you can show the relationship in UML by using the association between classes.
    2. Cardinality constraints in ERD (for example, one-to-one, one-to-many, many-to-many) can be shown in UML using multiplicity notation.
  3. Attributes
    1. This is probably the biggest similarity between ERD and UML. In both of these cases, attributes represent the properties. For ERD, it is properties of the entities and for UML, it is the properties of class.

So, in case of the following example, it is ERD between two tables using crows foot notation. This diagram represents the one to zero or many relation between user_profile table and public_post table. A user may have zero public post or more than one public posts.

Same this cane be represented using UML too. But in case of UML the relation is presented using 0, 1 or *. The * marks many in UML. So, in the following diagram but putting 0* it shows the same information as previous diagram. It shows the one-to-zero or many relation between these two classes.

Now, obviously it is a overly simplified example of both ERD and UML. But you can definitely further expand it to represent complex ERD structure using UML class diagrams.

The Data School
Author: The Data School