DEV Community

Cover image for Entity Relationship Diagrams
Mfon.
Mfon.

Posted on

Entity Relationship Diagrams

I remember the first time I purchased items from an e-commerce website - A 32GB flash drive, a boombox and a tripod - I did it with my phone. Pop-ups, redirects, eternally loading pages, having to type my card details and all those triggering experiences. However, nothing trumps the anxiety of waiting for the items to be delivered immediately after payment. I know you can relate. πŸ˜‚

Waiting for delivery meme

I didn't quite understand the process, but the website was functional. I got my items delivered as scheduled. They looked nothing like what I paid for on the website. Yes, you are right! The no return, no refund policy. I couldn't return the items or get a refund. Moreso, replacing them would have been such a drag. I just had to keep them. πŸ€·πŸ½β€β™‚οΈ

I'm a junior backend engineer now, and I appreciate the thought and work put into creating these applications.

Apps have complex systems that comprise different entities interacting with one another.

Think about how your favourite e-commerce platforms process millions of orders from millions of people around the world by the second. Crazy, right?! These operations are so effective that users trust and recommend them to others.

Software engineers have to visualize the entities involved using an Entity Relationship Diagram or Model to implement these complex features.

What is an Entity Relationship Diagram?

ER Diagrams are used for relational database design to illustrate how entities and their attributes interact within a system.

Entity Relationship Diagram Image Source

How it Started

Many principles we apply today can be traced back to the works of Aristotle. Nevertheless, some brilliant minds have made their marks in the world of technology.

Peter Chen Image Source

In 1976, Peter Pin-Shan Chen published a seminal paper titled "The Entity-Relationship Model: Toward a Unified View of Data." He is renowned for creating entity relationship modelling for database design. James Martin, the Father of CASE, added ERD refinements.

The Computer-Aided Software Engineering (CASE) process helped automate defining a data dictionary directly from the description of a business process. This automation marked a milestone in modern business software engineering.

Components of an Entity Relationship Diagram

  • Entity: This includes anything that you can define. Think of nouns like people, products, events or anything with data.

Example of Entities Image Source

Entities can be in types, sets, or categories. For example, electronic appliances would be an entity type. Entity sets are like entity types but also include an element of time. An example could be the iPhones ordered yesterday.

  • Relationship: This refers to how entities interact with one another. Think of relationships as a verb. Take for instance, users signup for newsletters.

Relationship Image Source

  • Attribute: This refers to the data that qualifies the entities. For example, name, age and phone number. Think of attributes as adjectives.

Attribute Image Source

  • Cardinality: This represents the numerical attributes of the relationships between entities or entity sets.

Cardinality Image Source

How To Draw a Basic Entity Relationship Diagram

1. Purpose
Understand the purpose and scope of the system you intend to design.

2. Entities
Enumerate the entities involved. Map them out in different rectangles as you see fit.

Entities in ERD Image Source

3. Attributes
Factor in more details by adding attributes of the entities.

Attributes in ERD Image Source

4. Relationships
Consider the relationships within your system. One way to do this is by answering this question, what does the ___ do with the ___? The customer purchases the car. The student signs up for the newsletter, and so on.

Relationships in ERD Image Source

5. Cardinalities
The notations help your ERD reader to understand the interactions between the entities. At a glance, they will know if there are zero, one, many, or some combination of those interactions.
Cardinalities in ERD Image Source

6. Save
You can save and export the file.
ERD complete Image Source

Now, I am beginning to understand what happens when I use applications. I am most definitely less critical. πŸ˜…

Happy coding! πŸ–€

Resources

  1. A Short History of the ER Diagram and Information Modelling
  2. Entity Relationship Diagram - ERD
  3. ER Diagrams
  4. How to Draw an Entity Relationship Diagram
  5. What is Entity Relationship Diagram

Cover Image Credit

Top comments (4)

Collapse
 
adamgalloway profile image
Adam Galloway

Great article! ERDs are often neglected but can be so useful for new developers working on a project. There are tools out there to automate their generation from your database or schema definitions!

Collapse
 
themfon profile image
Mfon.

Thank you, Adam. 😊

Yes, there are tools to do just that. Great times we live in. πŸ’―

Collapse
 
zeelyha profile image
Zeelyha

Really great write-up.πŸ‘

Collapse
 
themfon profile image
Mfon.

Thank you, Z