Database Schema - simply-nourish/nourish-app GitHub Wiki

Database Schema

Updated 4/28/18
fk = foreign key
pk = primary key

Primary Tables

Users

  • id (pk)
  • first_name (string)
  • last_name (string)
  • email (string)
  • nickname (string)
  • password_digest (string)
  • default_servings (int)

Recipes

  • id (pk)
  • user_id (fk reference to Users)
  • title (string)
  • summary (text)
  • instructions (text)

Ingredients

  • id (pk)
  • name (string)
  • ingredient_category_id (fk reference to IngredientCategories)

IngredientCategories (e.g., grocery store aisle: "Dairy", "Produce")

  • id (pk)
  • name (string)

DietaryRestrictions

  • id (pk)
  • name (string)

MealPlans

  • id (pk)
  • user_id (fk reference to Users)
  • name (string)

ShoppingLists

  • id (pk)
  • user_id (fk reference to Users)
  • name (string)

Measures

  • id (pk)
  • name (string)

Join Tables

* = alphabetized per Rails convention

UserFavorites

  • user_id (fk reference to Users)
  • recipe_id (fk reference to Recipes)

Dietary_Restriction_Users (User dietary restrictions)*

  • user_id (fk reference to Users)
  • restriction_id (fk reference to Restrictions)

MealPlan_Recipes

  • recipe_id (fk reference to Recipes)
  • mealplan_id (fk reference to MealPlans)
  • day (integral enumerated type: monday, tuesday, ..., sunday)
  • meal (integral enumerated type: breakfast, lunch, dinner, snack)

Ingredient_ShoppingList (Shopping list ingredients)*

  • list_id (fk reference to ShoppingLists)
  • ingredient_id (fk reference to Ingredients)
  • amount (float?)
  • measure_id (fk reference to Measures)

Ingredient_Recipes (Recipe ingredients)*

  • ingredient_id (fk reference to Ingredients)
  • recipe_id (fk reference to Recipes)
  • amount (float?)
  • measure_id (fk reference to Measures)

Dietary_Restriction_Recipes (Recipe dietary restrictions)*

  • recipe_id (fk reference to Recipes)
  • restriction_id (fk reference to DietaryRestrictions)