Entity Relationship Diagrams explained by Sonic the Hedgehog
Tags: database, sql, beginners, datamodel
Published: 2019-05-20 19:10:34

---
title: Entity Relationship Diagrams explained by Sonic the Hedgehog
published: true
description: On first glance, Entity Relationship Diagrams may look like a spaghetti mess. This post hopes to demystify how they fit together with Sonic the Hedgehog
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/8orv62uownccxm89lypq.png
tags: #database, #sql, #beginners, #datamodel

---

The Entity-relationship diagram (ERD) shows the relationships between tables and the common keys that connect them. Initially, they may appear to be a jumble of spaghetti noodles.

In this example, I'll use data from my favorite Sega Master System game, Sonic the Hedgehog, and illustrate how the zones, acts, and boss levels work together.


----------


>  [Conceptual Data Model](#chapter-1)
>  [Logical Data Model](#chapter-2)
>  [Physical Data Model](#chapter-3)
>  [What do the circles and arrows mean?](#chapter-4)
>  [Which systems can we model?](#chapter-6)
>  [How do we start?](#chapter-7)



---------------


<a name="chapter-1"></a>
## Conceptual data model

Level one! 

The conceptual data model. This is a high-level overview of the different entities in the model and their relationships.


![conceptual-data-model](https://thepracticaldev.s3.amazonaws.com/i/avcvinesuv6u90b7h77z.PNG)

In our example, we show that in Sonic the Hedgehog 1, zones can have many acts, these levels may have special stages, may have bosses, but there is only one boss per zone.

This model features entities, the rectangles. This is a physical thing, a fact or an event. The relationships between these entities are shown with diamonds. 

---------------

<a name="chapter-2"></a>
## Logical data model

The logical data model adds more details to our model. In this diagram, we add the relationships between the tables using crows foot notation (more on that in a little bit) and add primary and foreign keys to show exactly how they are related.


![logical-data-model](https://thepracticaldev.s3.amazonaws.com/i/fix9x96g2zptbm6g10f9.PNG)



---------------

<a name="chapter-3"></a>
## Physical data model

And finally the physical data model shows how the model will actually be implemented. This features the data types and names of the tables in our database.  In this case, all the tables record attributes so are dimensions.

![physical-data-model](https://thepracticaldev.s3.amazonaws.com/i/qif8s6as8pp2hlt0kmj6.PNG)


  


---------------


<a name="chapter-4"></a>
## What do the circles and arrows mean?

This is called crows foot notation and shows the relationships by using a 'crows foot', line or circle on either side of the line connecting the entities.

![ERD-crows-foot-notation](https://thepracticaldev.s3.amazonaws.com/i/gjzq00ltrbmxqjx7i1wp.PNG)


---------------

<a name="chapter-6"></a>
## Which systems can we model?

Structured data in relational systems.  We need to be able to see relationships in the form of tables, columns and keys.



---------------

<a name="chapter-7"></a>
## How do we start?

[Lucidchart](https://www.lucidchart.com/pages/) does a great job of making it easy to map out your diagram when you are ready to publish, but there are many tools out there to help you get started.

The very best way to get started is with a low tech option. Get out a pen and a big piece of paper. Make this your first step before you open the tools. Plus it will get you away from your screen for a little bit. Good luck!



---------------

## Read more 

{% link https://dev.to/helenanders26/sql-series-from-a-to-z-2pk9 %}