ENTITY RELATIONSHIP DIAGRAM – RECIPES

An ERD/M or Entity Relationship Diagram/Model is a graphical representation of entities and their relationships to each other.

In the context of websites, it is the logical process of the user navigating through a series of processes that are linked together, but can only be processed in one direction, for example:

ER-Diagram-Example-2

A single shopper can buy many items, and parallel to this, many items can only be bought by a single shopper.

Continuing from this, many items can have many prices, but each individual price must be contributed to a single item.

In light of this I created a diagram for an on line recipe book that each user can upload multiple recipes, and each recipe can have multiple pictures and comments, but each comment and picture cannot exist without the recipe entity existing first, this creates the idea of “crows feet”, logical lines that extend into one (or many) entities, but can only travel in one direction.

erd

The logic behind ERD’s is quite confusing as there are multiple definitions for the same things in different contexts, for example the primary (_id) key in the user entity is also the foreign (_id) key in the recipe entity, and so on and so forth. A user entity can exist without a recipe entity, but a recipe entity cannot exist without a user entity, the same for pictures and comments, a user would not be able to post a comment or a picture without having a recipe to post it to.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s