Welcome Guest, Not a member yet? Register   Sign In
Building a Food Recipe website.
#2

You need the users ID added to each entry in the recipes table, so that you know what recipes belong to what user.
But you do not need to have the users ID in the other tables though, they only need the "parents" id. That would mean recipes ID for ingredients & direction tables. And measurements only need the ingredients ID.

In a try to describe the relations.
  1. A users have a recipe.
  2. A recipe have some ingredients and some directions.
  3. A ingredient have a measurement.

I would do the setup this way
Users
id
name
email
password

Recipes
id
users_id
name
image
rating

Ingredients
id
recipes_id
name
sive

Directions
id
recipes_id
direction
prep_time
cook_time

Measurements
id
ingredients_id
name

I would also recommend setting up relations so that if a recipe is deleted from the database, all entries in ingredients, directions and measurements that belong to that recipe get deleted from the database automatically. Here is some information on that.
Reply


Messages In This Thread
Building a Food Recipe website. - by bellsdesign - 04-01-2015, 12:11 PM
RE: Building a Food Recipe website. - by silentium - 04-01-2015, 05:08 PM
RE: Building a Food Recipe website. - by RobertSF - 04-02-2015, 12:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB