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

(04-01-2015, 06:56 PM)bellsdesign Wrote: Any thoughts on my problem with the recipe page. I need help with the model. Should I have a model for every table or can I do it all one. On one page I'm trying to add to four different tables. The recipe table, ingredients table, descriptions table and the measurement table.

If every user will have their own recipies, then sure, each recipe should have the id of the user that owns it.

As far as a model for every table, no, you can certainly include more than one model per table. In the case of users, you would have one model and one table, users. That's because when you add users or modify their information, you only need to access the users table. But if you're adding or editing recipies, or anything that involves related tables, then you include all those tables in one model.

I don't mean to make your design more complicated, but if you have ingredients linked to a recipe, then you're going to have to duplicate rows in your ingredients table for common ingredients like salt, sugar, onions, tomatoes, etc. You need a third table between recipes and ingredients, like this (skeletal).

RECIPES
id
user_id
name

QUANTITIES
id
recipe_id -- links to recipes table
ingredient_id -- links to ingredients table
quantity

INGREDIENTS
id
name

If someone removes a recipe, you delete the recipe row and the quantity row, but you leave the ingredients table alone because other recipes use it too.

If you're not familiar with the subject, google for "database normal form." There should be some good tutorials out there.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
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 RobertSF - 04-02-2015, 12:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB