An Entity-Relationship Diagram (ERD) is a way to visualise relationships between tables and the common keys between them. On first glance, they may look like a spaghetti mess. This post hopes to demystify the language and how they fit together with the help of Sonic the Hedgehog.
In this example, I'll be using data from my favourite Sega Master System game, Sonic The Hedgehog 1 and illustrating how the Zones, Acts and Boss levels fit together.
The Conceptual Data Model, this is a high-level overview of the different entities in the model and their relationships.
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.
Next up ... The Logical Data Model which 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.
And finally ... The Physical Data Model, that 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.
Read more about the differences between Dims and Facts:
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.
The Business Intelligence (BI) team uses them when modelling data to determine requirements, show users how the tables fit together, and to debug systems.
Read more about what the BI team does and how they are different from Data Scientists:
Structured data in relational systems. We need to be able to see relationships in the form of tables, columns and keys.
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.
Lucidchart 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.
- Don't join relationships to relationships
- Use lots of colour ... wisely
- Make entity and attribute names easy to understand
- Know your audience - are you doing this for a user in management or to implement a new data model?
- Don't overthink it if you don't have to. :)
This post first appeared on helenanderson.co.nz
Photo by Giphy