Entity Relation Diagram (ERD): A step-by-step guide

Satish Pradhan
4 min readJun 16, 2024

--

Entity relation diagram(ERD) also called Entity relation model. ERD is a visual illustration that describes the logic within the different entities(table) and how individual components relate to each other.Most commonly used in database design.

Entity

Entities are the core concept of ERD which represent the metadata of a real-world object (table) that we want to store in a database. For example in the case of e-commerce database entities will be customer, product, order, payment etc. The visual representation of the entity is a simple rectangle.

entity

Weak Entity

There is another type of entity which is a weak entity. Weak entities are those entities which can’t logically exist with their own value, it depends on the parent entity. In simple terms, the table can’t exist on its own. For example, a review or rating table can’t exist on its own; it depends on the customer and product entity. It is represented by a nested rectangle.

weak entity

Attribute

Attribute (column) is the property or characteristic of an entity. For example, a customer entity has the following attribute name, address, email etc . Represented by oval or circular. There are different types of attributes that define properties or characteristics of attributes.

type of attribute

simple attribute

Simple attributes are fields that are atomic or can’t be broken down any further , represented as simple oval. As in the above diagram, Email and Image are simple attributes.

Composite attribute

Composite attributes are made of more than one simple attribute. Represented by a tree of simple attributes. Above address field is a composite attribute.

Derived attribute

Derived attribute is a field whose value changes depending on other attributes. For example “age” is a derived attribute that depends on date of birth. Represented by a dash oval. membership attribute depend of date of payment or membership expire date.

MultiValued attribute

Multivalued attributes are the fields which have multiple values. For example, users can have multiple phone numbers. Represented by concentric oval.

key attribute

The name describes a unique field in a table. For example primary key or username. Represented by oval and underline below the field.

Relationship

Relationships are a core part of ERD. when an entity is related to an entity. There are three types of relationships, one to one, one to many and many to many. In ERD many to many relations are good or bad I don’t know, because most of the time many to many tables are interconnected by junction table which have one to many connections between different tables. Represented by diamond shape.

relationship

Cardinality

Cardinality refers to the maximum number of times an instance in one entity can relate to instances of another entity. Its visual representation of one is a vertical line and many as crow foot notation.

below example

Below example, show that one customer has multiple orders but an order has one and only one customer.

Modality

A concept to indicate whatever relation is required or optional. For required it has to have another vertical line in relation line and for optional a zero in relationship line.

For example a customer can have no order or order, but order has to have a customer

--

--