Open RosemaryGonzaga opened 4 years ago
Hi Rosemary! So much awesome feedback. Thank you so much for taking the time! Some questions on the schema below:
time
column in my recipes
, would the data type be :time? or what would you recommend?All other updates on my Schema have been reflected as per your guidance. Also, I wasn't sure if those checkboxes are meant for you to check or myself! Apologies if I overwritten some of your notes! Let me know for future note. Thank you so much and I look forward to your feedback. Will go through the State Shape portion a little later after User Auth. Cheers! :)
Hey Nikki, it's clear you put a lot of thought into drafting your schema and frontend state. My hat's off to you for all your great questions!
The design doc rubric is below, along with my feedback. Please let me know if you have any questions!
Database Schema
back_ticked
back_ticked
back_ticked
Comments
recipes
:reviews
table)calories
column for now (you can always addsodium
,fat
,protein
,carbs
,fiber
columns later)ingredients
column; these need to be stored in a separate table, and you can use arecipe_ingredients
joins table to link recipes with their ingredients. (One principle of designing a "normalized" database is that each column should only store one value, not a collection of values. If arecipe
can have many ingredients and aningredient
can have many recipes, we should use an intermediate join table to facilitate this many-to-many relationship.)nutrition
column tocalories
(as mentioned in response to your question above).cuisine_id
andcourse_id
so that users can search recipes by cuisine or course. (From browsing Yummly, I gather that Yummly only classifies each recipe under a single cuisine and a single course, which means each recipe will only have one associatedcuisine_id
andcourse_id
.)icon_url
. You should consider eventually storing your recipe images in a cloud service (AWS S3) and managing references to those files via Active Storage... which means you won't need to store theicon_url
in therecipes
table. I wouldn't worry about AWS until towards the end of the 2-week sprint; until then, you can just use locally-stored placeholder images for your recipes.description
anddirections
to have atext
datatypeingredients
andrecipe_ingredients
ingredients
andrecipe_ingredients
recipe_ingredients
can look similar to the design that you proposed for yourrecipe_tags
table (i.e, you need a way to link arecipe
with aningredient
)cuisines
andcourses
cuisines
andcourses
that Yummly uses to categorize recipes.favorites
, oruser_preferences
favorites
oruser_preferences
table. If the user profile or personalized browse feed is going to be one of your main features, you'll need a place to store the user's preferences. When a user goes through the "personalize your experience" form on Yummly, they're asked to select preferences across many different dimensions: cuisine, allergies, diet, ingredients (to exclude), cooking skills, cooking goals. You should limit it to just two few of those:cuisine
,ingredients
.user_id
,preferable_id
andpreferable_type
columns, you may want an additional column to indicate whether the specific preference represents something to include or exclude. (E.g., include the selected cuisines but exclude the selected ingredients)Bonus tables
bloggers
,recipe_tags
,hash_tags
,reviews
,,likes
,flags
, or move them to the very bottom of your schema plan under a "BONUS" section.Sample State
```javascript...```
). This will display the state as a code block instead of a giant line of textentities
session
errors
(here or inui
)ui
(if needed)comments
inside ofposts
Comments
recipesIds
key in yourusers
slice of frontend state. However, conventionally, the keys that store an array of ids should be named assingularResourceIds
, e.g.,recipeIds
andreviewIds
.recipes
feature, you can think about how to send an array ofrecipeIds
back with every request for user info. At that point, you might want to look into ActiveRecord'scollection_singular_ids
method, which you'll be able to use in your jbuilder. Assuming you define ahas_many :saved_recipes
association in yourUser
model, Rails will automatically give you a#saved_recipe_ids
instance method that generates an array of ids for all thesaved_recipes
associated with a user.collection_singular_ids
in sections 4.3.1 and 4.3.1.6-7 in the Rails Association Basics guide.icon_url
column in your database tables, you'll want to keep theiconUrl
key in your frontend state. This will be generated via an association method that you define in your models. (If this doesn't make sense now, that's ok. It will make more sense after you go through the AWS S3 tutorial much later in your project.)ingredients
key in yourrecipes
slice of state should point to an array ofingredientIds
, not an array of actual ingredient names. The reason this matters is b/c you don't wantingredients
to be listed in more than one place. (There should be a single source of truth for every piece of information.) All your ingredients should instead be listed in a separateingredients
slice of state underentities