{"id":1230,"date":"2019-05-20T20:00:10","date_gmt":"2019-05-20T08:00:10","guid":{"rendered":"http:\/\/www.helenanderson.co.nz\/?p=1230"},"modified":"2020-05-10T20:12:22","modified_gmt":"2020-05-10T08:12:22","slug":"entity-relationship-diagrams","status":"publish","type":"post","link":"https:\/\/www.helenanderson.co.nz\/entity-relationship-diagrams\/","title":{"rendered":"Entity relationship diagrams"},"content":{"rendered":"\n

Entity-Relationship Diagrams (ERD) are a way to visualise relationships between tables and the common keys between them. On first glance, they may look like a spaghetti mess.<\/p>\n\n\n\n

This post hopes to demystify the language and how they fit together with the help of Sonic the Hedgehog.<\/p>\n\n\n\n


\n\n\n\n

Conceptual Data Model<\/a>
Logical Data Model<\/a>
Physical Data Model<\/a>
What do the circles and arrows mean?<\/a>
Who uses these diagrams?<\/a>
Which systems can we model?<\/a>
How do we start?<\/a>
Any gotchas?<\/a><\/strong><\/p><\/blockquote>\n\n\n\n


\n\n\n\n

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.<\/p>\n\n\n\n


\n\n\n\n

<\/a><\/p>\n\n\n\n

Conceptual Data Model<\/h2>\n\n\n\n

Level one!<\/p>\n\n\n\n

The Conceptual Data Model, this is a high-level overview of the different entities in the model and their relationships.<\/p>\n\n\n\n

<\/figure><\/div>\n\n\n\n

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.<\/p>\n\n\n\n

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.<\/p>\n\n\n\n


\n\n\n\n

<\/a><\/p>\n\n\n\n

Logical Data Model<\/h2>\n\n\n\n

Next up … The Logical Data Model which adds more details to our model.<\/p>\n\n\n\n

<\/figure><\/div>\n\n\n\n

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<\/a> to show exactly how they are related.<\/p>\n\n\n\n


\n\n\n\n

<\/a><\/p>\n\n\n\n

Physical Data Model<\/h2>\n\n\n\n

And finally … The Physical Data Model, that shows how the model will actually be implemented.<\/p>\n\n\n\n

<\/figure><\/div>\n\n\n\n

This features the Data Types and names of the tables in our database. In this case, all the tables record Attributes so are Dimensions.<\/p>\n\n\n\n


\n\n\n\n

<\/a><\/p>\n\n\n\n

What do the circles and arrows mean?<\/h2>\n\n\n\n

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.<\/p>\n\n\n\n

<\/figure><\/div>\n\n\n\n
\n\n\n\n

<\/a><\/p>\n\n\n\n

Who uses these diagrams?<\/h2>\n\n\n\n

The Business Intelligence (BI) team uses them when modelling data to determine requirements, show users how the tables fit together, and to debug systems.<\/p>\n\n\n\n


\n\n\n\n

<\/a><\/p>\n\n\n\n

Which systems can we model?<\/h2>\n\n\n\n

Structured data in relational systems. We need to be able to see relationships in the form of tables, columns and keys.<\/p>\n\n\n\n


\n\n\n\n

<\/a><\/p>\n\n\n\n

How do we start?<\/h2>\n\n\n\n

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.<\/p>\n\n\n\n

Lucid Chart<\/a> 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.<\/p>\n\n\n\n


\n\n\n\n

<\/a><\/p>\n\n\n\n

Any gotchas?<\/h2>\n\n\n\n