Skip to content
Owais Khan Software Reviews
How-To Guides

what is an er diagram mention its basic components

An ER diagram maps database entities, attributes, relationships, lines, and cardinality, with a worked example and notation caveats.

By Owais Khan

An entity-relationship diagram (ER diagram or ERD) is a visual representation of how items in a database relate to one another. Its basic components are entities, attributes, and relationships; ERDs commonly show them with rectangles, ovals, and diamonds joined by lines, and may also show cardinality.

What an ER diagram represents

An ERD is a specialized type of flowchart for showing relationship types between entities in a system. In relational database design, it provides a high-level conceptual view of how database entries are connected. That makes it useful both for planning a new database and for documenting or examining an existing one.

The word “entity” means a definable thing about which information can be stored. Depending on the system, an entity may be a person, role, event, concept, or object. In a relational database context, entities refer to tables. An ERD then adds the properties that describe those entities and the relationships that connect them.

An ERD is not the same as a database schema or a data-flow diagram. A schema establishes rules for organizing a relational database, such as table names, fields, and data types. A data-flow diagram instead shows how data moves through a process or system. An ERD concentrates on the entities in a database and the relationships among them.

The basic ER diagram components

The simplest answer is three core components: entities, attributes, and relationships. Connecting lines and cardinality are also important diagram elements, but sources describe the count differently: some identify three basic components, while another description lists five components by treating actions and connecting lines separately.

Component What it means Common traditional symbol
Entity An object or concept that can have information stored about it Rectangle
Attribute A property or characteristic of an entity Oval or ellipse
Relationship The connection that shows how entities share information Diamond
Connecting line A line joining attributes and entities or showing relationships Solid line
Cardinality The numerical nature of a relationship between entities Notation placed on or beside the connection

Entities

An entity is the main subject represented in the database. For example, a system might need to store information about a parcel or a locker. Each would be an entity because each has information that the system needs to retain.

Many ERD styles display an entity as a rectangle. An entity type is a category of entities, while the individual entities in that category are instances. Keeping those levels separate helps distinguish the general structure from the particular records that populate it.

Entities can also be classified as strong or weak. A strong entity has enough identifying information in its attributes to stand on its own. A weak entity depends on another entity for its meaning or identification and is commonly shown with a double rectangle. The related strong entity is called the parent or owner entity.

Attributes

Attributes describe an entity. If Parcel is an entity, its attributes might include a parcel code, destination zone, and weight. In the traditional notation, attributes are shown as ovals or ellipses connected to the relevant entity.

An attribute can have a special role. A key attribute is the unique, distinguishing characteristic of an entity. A multivalued attribute can have more than one value. A derived attribute is based on another attribute. These distinctions matter because they tell the reader whether a field identifies a record, can repeat, or is calculated from other stored information.

Relationships

A relationship expresses how two entities are connected. In traditional ER notation, it is represented by a diamond placed between the related entity rectangles. The relationship should communicate the relevant association, such as a parcel being stored in a locker.

Relationships may connect different entities, and an entity can also be self-linked. In a conceptual reading of a diagram, entities often behave like nouns, while relationships communicate the action or connection between them.

Connecting lines

Lines make the diagram readable by linking an entity to its attributes and connecting entities to their relationships. In the conventional symbol set, these are solid lines. They do not replace the entities, attributes, or relationships; they show how those components belong together.

Cardinality

Cardinality specifies how many instances of one entity can relate to an instance of another entity. Common forms include one-to-one, one-to-many, many-to-one, and many-to-many. Cardinality can also indicate whether participation is optional or mandatory.

Cardinality is not always drawn in the same way. Some ERDs use numerical labels, while other notations use different visual marks. Its purpose remains the same: to make the allowed quantity of related instances explicit.

Worked example: a parcel-and-locker ER diagram

The following is a new example showing how to move from requirements to a small ERD. The example uses concrete records, but the component rules come from the ERD conventions above.

Step 1: Identify the entities

Suppose a storage service needs to track parcels and the lockers holding them. The two things about which the system stores information are:

  • Parcel
  • Locker

They become the two entity rectangles. The example does not treat a single parcel code or locker code as an entity; those are values belonging to the entities.

Step 2: List the attributes

Give each entity properties that the system must retain:

  • Parcel: parcel_code, destination_zone, weight_kg
  • Locker: locker_code, aisle

Choose a key attribute for each entity. In this example, parcel_code distinguishes one parcel from another, and locker_code distinguishes one locker from another.

Step 3: State the relationship

The relationship is stored_in. It connects Parcel and Locker because the diagram needs to show where each parcel is held.

Step 4: Choose the cardinality for this design

For this particular design, one locker may hold several parcels, while each parcel is assigned to one locker at a time. Therefore, the relationship is one-to-many when read from Locker to Parcel.

This is a design input, not a universal fact about lockers. If the business rule changed, the cardinality in the ERD would change too.

Step 5: Represent the structure

A compact text version of the traditional structure is:

( locker_code ) [ Locker ] 1 -------- < stored_in > -------- many [ Parcel ]
( aisle ) ( parcel_code )
 ( destination_zone )
 ( weight_kg )

The brackets stand for the entity rectangles, the parentheses stand for attribute ovals, and the angle brackets label the relationship diamond in a text-only representation. A drawn ERD would use the relevant shapes rather than these text substitutes.

Step 6: Populate the model with concrete values

Use these records:

Locker
L-07 | aisle C
L-08 | aisle A

Parcel
P-204 | zone Z3 | 2.4 kg
P-205 | zone Z1 | 0.8 kg
P-206 | zone Z3 | 4.1 kg

Apply the one-to-many rule to produce the relationship instances:

stored_in
P-204 -> L-07
P-205 -> L-07
P-206 -> L-08

The result shows two parcels connected to L-07 and one parcel connected to L-08. The diagram’s structure stays the same while the values change: the rectangles still represent Parcel and Locker, the ovals still represent their attributes, the diamond still represents stored_in, and the cardinality still describes the allowed connection.

Inputs that change the ERD

The answer is not determined by shapes alone. Several design inputs can change what appears in the diagram.

The notation style

A traditional Chen-style ERD uses separate connected symbols for entities, relationships, and attributes. Another style, IDEF1X, connects entities directly without separate relationship symbols and places attributes inside a table-like entity shape. Therefore, an ERD may communicate the same logical structure while looking different.

The business rule behind cardinality

In the worked example, the rule was “one parcel has one locker, and one locker can contain many parcels.” If parcels could occupy multiple lockers, the relationship would need a different cardinality. If a locker could exist without a parcel, or a parcel could exist before assignment, optional participation would need to be represented. Cardinality is consequently an input derived from the intended relationship, not merely a decorative label.

Whether a relationship needs its own data

Sometimes a relationship between two entity sets has attributes of its own. In that case, an associative entity can link the entity instances while holding information about the relationship. Associative entities are also used to inform junction tables in relational databases.

Whether an entity is independent

If an entity has sufficient identifying attributes, it can be modeled as strong. If it only has meaning in the context of another entity, it can be modeled as weak and shown with the notation for a weak entity. This distinction can change both the shape and the connections in the diagram.

The modeling level

ERDs may be created as conceptual, logical, or physical data models. A conceptual model gives an overview of the project scope and how data sets relate. A logical model adds more detail about attributes and relationships. A physical model describes the blueprint for a physical implementation, such as a relational database.

Cases where the simple three-part answer is incomplete

The three-part answer is useful, but it can give the wrong impression if treated as a rigid standard.

First, connecting lines may be counted as a separate component. One source describes three main components—entities, relationships, and attributes connected by lines—while another lists five basic components: entities, attributes, relationships, actions, and connecting lines. The safest explanation is to identify the three conceptual building blocks and then mention the supporting lines, relationship actions, and cardinality notation.

Second, not every ERD uses a rectangle, oval, and diamond for every item. Traditional ERDs use those symbols, but IDEF1X-style diagrams can put attributes inside entity shapes and omit separate relationship symbols. The meaning matters more than assuming every diagram uses identical shapes.

Third, relationships are not always just simple links. A relationship can have its own attributes, which calls for an associative entity. An entity can also be weak, meaning that it depends on a parent or owner entity rather than being fully identified by its own attributes.

Fourth, cardinality is more informative than simply drawing a line. A line may show that two entities are connected, but cardinality explains whether the connection is one-to-one, one-to-many, many-to-one, or many-to-many and whether participation is optional or mandatory.

Finally, an ERD is most suited to data that can be organized relationally. It does not sufficiently represent semistructured or unstructured data on its own. For relational database work, however, it provides a useful conceptual starting point for design, documentation, analysis, and troubleshooting.

A practical way to make one

Start by listing the things about which the system must store information. Turn those things into entities, then list their properties as attributes. Select identifying attributes, connect related entities with named relationships, and determine cardinality from the business rules. Finally, review whether any entity is weak, whether a relationship needs to become associative, and whether the chosen notation matches the level of detail required.

After that manual pass, if the starting material is Postgres DDL, the Postgres DDL to Mermaid Converter is an option to consider for avoiding the manual redraw step. The conceptual decisions still need to be checked: the tool does not replace deciding which entities, attributes, relationships, and cardinalities accurately describe the system.

Summary

An ER diagram is a visual model of database entities and their relationships. Its three core components are entities, attributes, and relationships, usually represented by rectangles, ovals, and diamonds. Lines connect the parts, while cardinality records how many instances may participate in each relationship. The exact appearance and even the component count can vary by notation, and weak entities, associative entities, relationship attributes, optional participation, and modeling level can make a diagram more detailed than the simple three-component summary.

Open the Postgres DDL to Mermaid Converter

Frequently asked questions

What are the three basic components of an ER diagram?
The three core components are entities, attributes, and relationships. Entities are commonly rectangles, attributes ovals or ellipses, and relationships diamonds; connecting lines show how those parts are linked.
Are connecting lines an ER diagram component?
Yes, connecting lines are an important diagram element. Sources differ on whether they are counted among the three basic components or listed separately with actions, so it is clearest to mention them as supporting elements.
What does cardinality mean in an ER diagram?
Cardinality describes how many instances of one entity can relate to an instance of another. Common forms include one-to-one, one-to-many, many-to-one, and many-to-many, with notation that can also show optional or mandatory participation.
What is a weak entity?
A weak entity depends on another entity for its meaning or identification because its own attributes are not sufficient. It is commonly shown with a double rectangle and is associated with a parent or owner entity.
Does every ER diagram use rectangles, ovals, and diamonds?
No. Traditional ERDs use those separate shapes, while IDEF1X-style diagrams can connect entities directly and place attributes inside table-like entity shapes without separate relationship symbols.