DEV Community

philip-haines
philip-haines

Posted on

Setting Up for Success: A Guide to ERD's

So, what is an ERD? To start, it stands for Entity Relationship Diagram, and it isn't actual programming. An ERD is the first step in setting yourself up for success in Object Oriented Programming (oop). As I began dipping my feet into the oop waters it quickly became clear that having a well organized plan of attack would set me up for success, this is where ERDs came in.

In short, an ERD is a hand drawn diagram that represent relationships between objects in your program. Think of an ERD as an electrician's blueprint of how everything is connected under the hood. Your ERD blueprint will do the same thing. Having the visualization of all of the methods needed for each class you create, and other data needed at initialization will save many head aches later down the road.

ERD's are also important in helping other developers who may not be familiar with your project have an understand of relationships in your database. The best thing for readability is to stick to convention.

These are the notations that you should use in your ERD:
ERD Cardinality

So how does this all look when it's put together? Blank diagram

If we look at this diagram you can see that we have two classes, "User" and "Food". A User can eat many Food objects, and Food objects can be eaten by many User objects. These classes are joined by a "Meal" joiner object, a User eats many Food objects at a Meal.

By using an ERD there is now a clear blueprint as to the data each class initializes with, the methods that will need to run on all of the classes, and the relationships that persist.

Is creating an ERD necessary? Maybe not, but hopefully this post will help you understand why it's important and how it will set you up for success on your next project.

Top comments (3)

Collapse
 
zdev90 profile image
Yujun Zhang

@philiphaines , nice article. BTW, is there any chance to talk to you in private?

Collapse
 
philiphaines profile image
philip-haines

@yujunz Please feel free to reach out any time. My apologies for being late with a reply, have been busy with some other projects!

Collapse
 
zdev90 profile image
Yujun Zhang

@philiphaines what's ur email to contact ?