Entity Relationship Diagram (ERD)
What is an Entity Relationship Diagram (ERD)?
ERD stands for entity relationship diagram. People also call these types of diagrams ER diagrams and Entity Relationship Models.
An ERD visualizes the relationships between entities like people, things, or concepts in a database. An ERD will also often visualize the attributes of these entities.
By defining the entities, their attributes, and showing the relationships between them, an ER diagram can illustrate the logical structure of databases.
This is useful for engineers hoping to either document a database as it exists or sketch out a design of a new database.
Why Make an ERD?
An ER diagram can help businesses document existing databases and thereby troubleshoot logic or deployment problems or spot inefficiencies and help improve processes when a business wants to undertake business process re-engineering. ERDs can also be used to design and model new databases and make sure that engineers can identify any logic or design flaws before they're implemented in production.
- Document an existing database structure
- Debug, troubleshoot, and analyze
- Design a new database
- Gather design requirements
- Business process re-engineering (BPR)
When documenting a system or process, looking at the system in multiple ways increases the understanding of that system. ERD diagrams are commonly used in conjunction with a data flow diagram to display the contents of a data store. They help us to visualize how data is connected in a general way, and are particularly useful for constructing a relational database.
The History of Entity Relationship Diagrams
Peter Chen developed ERDs in the 1970s and published his proposal for entity relationship modeling in a 1976 paper titled "The Entity-Relationship Model: Toward a Unified View of Data".
Peter Chen was a computer scientist who worked on improving database design. His entity relationship model was a way to visualize a database that unified other existing models into a single understanding that removed ambiguities. Prior to ERDs, there were three data models for databases: the network model, the relational model, and the entity set model.
Each had their own strengths and weaknesses, but none provided a complete view of the database.
With an ERD, Chen could provide a unified framework for database modeling.
Peter Chen's work was greatly influenced by scientists and engineers who came before him, specifically Charles Bachman, who worked on visualizing databases in the 1960s and his data structure diagrams became known as Bachman diagrams.
Chen's entity relationship model is in many ways the foundation for later practices like Unified Modeling Language or UML in information systems.
In the 1980s, another computer scientist named James Martin, worked to further refine Chen's ER model and introduced what's known today as the IE notation. IE notation uses Crow's foot to express cardinality (one to many relationship) instead of Chen's notation to epxress the same.
Types of ERD
ER diagrams will differ on how they express cardinality. They will also differ in how they display entities and their attributes and whether or not they show relationships or attributes as separate symbols.
The traditional Chen ERD is like a flowchart with connected symbols for entities, relationships, and attributes. Since its first introduction by Chen in the 70s, others have proposed different cardinality notations, but the basic symbols used and how they're connected tend to look the same.
IDEF1X Notation ERD - Relational Schema
IDEF1X stands for integrated definition for data modeling. This type of ER diagram will show entities connected to each other without relationship symbols. The attributes for any entity will be listed as part of a table inside each entity shape instead of separate symbols. Some also call this type of ER diagram a Relational Schema diagram.
Common ERD Symbols
An ER diagram has three main components: entities, relationships, and attributes connected by lines.
- Entities, which are represented by rectangles. An entity is an object or concept about which you want to store information.
A weak entity is an entity that must defined by a foreign key relationship with another entity as it cannot be uniquely identified by its own attributes alone.
- Relationships, which are represented by diamond shapes, show how two entities share information in the database.
In some cases, entities can be self-linked.
- Attributes, which are represented by ovals. A key attribute is the unique, distinguishing characteristic of the entity. For example, an employee's social security number might be the employee's key attribute.
A multivalued attribute can have more than one value. For example, an employee entity can have multiple skill values.
A derived attribute is based on another attribute. For example, an employee's monthly salary is based on the employee's annual salary.
- Connecting lines, solid lines that connect attributes and show the relationships of entities in the diagram.
- Cardinality specifies the numerical attribute of the relationship between entities. It can be one-to-one, many-to-one, or many-to-many.
Styles of Cardinality
Cardinality is the mathematical sense just means the number of values in a set. In relationship to databases and ERD, cardinality specifies how many instances of an entity relate to one instance of another entity.
Ordinality is also closely linked to cardinality. While cardinality specifies the occurrences of a relationship, ordinality describes the relationship as either mandatory or optional.
In other words, cardinality specifies the maximum number of relationships and ordinality specifies the absolute minimum number of relationships.
In other words, there will be multiple instances of each entity in a database. Cardinality allows you express the number of each entity that can be associated with another entity. For example, in an employee database, a manager will have multiple employee reports (in a one to many relationship), but an employee will only have one ID number (a one to one relationship). There are three main types of relationships in a database expressed using cardinality notation in an ER diagram.
There are many notation styles that express cardinality.
Information Engineering Style, IE Notation or Crow's Foot Notation
Entity Relationship Models can also vary based on the level of abstraction visualized. There are usually three models people refer to based on the level of detail you want to show: conceptual ERD, logical ERD, and physical ERD.
- Conceptual ERD or data model: This model has the most abstraction and least amount of detail, as such it's appropriate for large projects that need a higher level view used by business analysts. A typical conceptual ERD will contain entities and relationships, but offer no details on specific database columns or cardinalities. It's a general, high-level view of database design.
- Logical ERD or data model: This model adds more detail to the conceptual model by defining additional entities that are operational and transactional.
- Physical ERD or data model: This model serves as the actual design or blueprint of the database with lots of technical details including defining cardinality and showing primary and foreign keys of entities instead of just their abstract semantic names. For this type of ERD, attributes will often be listed to represent the columns of the real database table.
Documenting an Existing Database from Data
There are two reasons to create a database diagram. You're either designing a new schema or you need to document your existing structure.
If you have an existing database you need to document, you can create a database diagram using data directly from your database. You can export your database structure as a CSV file (there are some scripts on how to this here), then have a program generate the ERD automatically.
This will be the most accurate portrait of your database and will require no drawing on your part.
Here's an example of a very basic database structure generated from data.
This type of ERD will be considered a physical data model and will contain all the technical details of your database using IDEF1X notation.
If you want to create a new plan, you can edit the generated diagram and collaborate with your team on what changes to make.
Learn more about generating ER diagrams from data automatically using SmartDraw's ERD extension.
Watch this quick video learn more about ERD diagrams and their components.
Entity Relationship Diagram Tutorial
Here are some best practice tips for constructing an ERD:
- Identify the entities. The first step in making an ERD is to identify all the entities you will use. An entity is nothing more than a rectangle with a description of something that your system stores information about. This could be a customer, a manager, an invoice, a schedule, etc. Draw a rectangle for each entity you can think of on your page. Keep them spaced out a bit.
- Identify relationships. Look at two entities, are they related? If so draw a solid line connecting the two entities and add a diamond between them with a brief description of how they are related.
- Add attributes. Any key attributes of entities should be added using oval-shaped symbols.
- Complete the diagram. Continue to connect the entities with lines, and adding diamonds to describe each relationship until all relationships have been described. Each of your entities may not have any relationships, some may have multiple relationships. That is okay.
Tips for Effective ER Diagrams
- Make sure that each entity only appears once per diagram.
- Name every entity, relationship, and attribute on your diagram.
- Examine relationships between entities closely. Are they necessary? Are there any relationships missing? Eliminate any redundant relationships. Don't connect relationships to each other.
- Use colors to highlight important portions of your diagram.
Entity Relationship Diagram Examples
Browse SmartDraw's entire collection of ERD examples and templates