samstephen / 06-23-cookcolab

CookcoLab is an app that allows users to share recipes.
0 stars 0 forks source link

Tables #1

Open samstephen opened 9 years ago

samstephen commented 9 years ago

Tables

users

id (primary key) name (text)
1 "Sam"
2 "Lars"
3 "Patrick"
4 "Kristin"

categories

id (primary key) meal (text)
1 "breakfast"
2 "lunch"
3 "dinner"
4 "snack"

recipes

id (primary key) title (text) published_date (text) content (text) category_id (integer) user_id (integer)
1 "Bacon Pancakes with Maple-Peanut Butter Sauce" "2013-02-01 06:33:54.003" "content" 1 3
2 "Grilled Bacon Jalapeno Wraps" "2012-02-01 06:33:54.003" "content" 2 3
3 "Bacon Wrapped Smokies" "2012-02-01 06:33:54.003" "content" 2 1
4 "Bacon Explosion" "2015-02-01 06:33:54.003" "content" 3 2
5 "Dark chocolate Bacon Cupcakes" "2015-06-23 02:01:30.000" "content" 4 1

tags

id (primary key) tag (text)
1 "bacon"
2 "quick"
3 "sweet"
4 "chocolate"
5 "simple"
6 "cheap"
7 "grilled"
8 "egg"
9 "butter"

recipe_tags

recipe_id (integer) tag_id (integer)
1 1
2 1
3 1
4 1
5 1
2 3
7 2
1 8
samstephen commented 9 years ago

cookcolab_tables-01

samstephen commented 9 years ago

Explaining diagram

User to Recipe relationship

A user is assigned to a recipe. When selecting a user's recipe(s), the recipe(s) can be located using the user_id foreign key.

Recipe to Category relationship

A category is assigned to a recipe. When selecting a recipe, the category_id foreign key can be used.

RecipeTag

A recipe tag is an object that contains a recipe_id and tag_id. This is useful because there are many tags and recipes, one tag can belong to many recipes and a recipe can have many tags.