Week 2: Making a ER Diagram for COVID-19
Tags: beginners, datascience
Published: 2020-09-06 23:25:11

Hello everyone! 

Today, I continue my development by working on creating an ER diagram for my class. Specifically, I am making a diagram for COVID-19. While it may not be the cleanest or the most optimal diagram, I hope it is a solid foundation to build upon in the coming weeks.

COVID-19 has had many impacts on the world currently and the ripples of it will be felt for years to come. The diagram I have created attempts to look at some of the components that an individual has to take into consideration about their risk of contracting COVID. **Just to get this out of the way now, this is not a comprehensive list -- nowhere near that. This is just a few of the players in the game of COVID.**

So, looking at the diagram itself:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0nezbvkhbt5sqm9peiaa.png)

I put the entity "patient" in the middle of my diagram for a couple reasons. The first and most obvious one is that many of the other entities in the diagram have connections to the patient. So, having that central location made it a solid starting point. The other, less technical reason is that I believe it just looks better aesthetically in the middle; there's nothing else to it.

Looking at the majority of the attributes, most of them are quite intuitive; however, some of them are rather hard to put into tuples. I'll explain what I mean later. The hardest entity to create attributes for was the "risk" entity. While some of the basic risks are present (ex: contracting COVID-19), there are still some risks that we don't know of yet. Thus, I added the "long-term symptoms" attribute as a type of catch-all to encompass those potential unknown risks.

Finally, you may have noticed the notation on the lines connecting the entities. This is called "cardinality", which illustrates the relationship between the different entities. For example, looking the relationship between a geographic location and hospitals, there is a crow's foot with a circle on the line attaching "hospitals". This is to represent the fact that there _can_ be multiple hospitals in a singular geographic location. If there had to be multiple of some entity, the circle would be replaced with one of the solid lines seen in other parts of the diagram.

Jumping to the tuples (which is essentially a fancier name for a row or ordered list), some of them were harder to set up than others. For "geographic location", I decided to have my primary key be the country; so, the primary keys down below are Sweden, Italy and India, all of which are highlighted in red in the first image. 

Yet again, the "risks" entity turns out to be a bit of a pain. For this one, I have a patient ID act as a primary key, as if all of the entries were patients at a hospital. There is probably a better primary key out there, but I decided to run with this solution for the time being.


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hgetfa9pnci0dyl1jjoq.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lyi4wmj8n29f4b1i64oy.png)


Overall, I think I did relatively well on this project. Is it perfect? Absolutely not. There are probably attributes I missed that means that the diagram is not as fleshed out as it could be. However, for a beginner's first diagram, I think I did sufficient enough.

For a more in-depth explanation of my diagram and the tuples, make sure to watch my latest video! 

{% youtube 5vT8xyxm5x8 %}

Until next time,
Incerah