SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Rusted & Weathered HumanClay's Avatar
    Join Date
    Sep 2000
    Location
    Milwaukee, WI
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I have a question about designing a database to hold cooking recipes. The general format for all recipes is "Ingredients" , "Instructions" , "Notes"

    What would the best way to design a MySQL database be? I'm thinking the easiest way is to make 3 text fields, one for each category listed above. Is that an efficient way to do this? I'm not sure how else you could do this effectively. Any comments/help please. Thanks.
    Steve Caponetto - [profile] [e-mail]
    CreedFeed.com - feed your need for Creed!

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yup. The recipes themselves can probably be stored just as you've described. It's the library of databases that will take some structuring. For example, I assume you're going to group the recipes into categories, and you might want to also list the type of wine that goes with each one, preparation times, etc...
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  3. #3
    Rusted & Weathered HumanClay's Avatar
    Join Date
    Sep 2000
    Location
    Milwaukee, WI
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    kynak, yes, I have to work on the design of other databases, I was just wondering the best way to store the recipes themselves. I will stick to the way I described then, unless of course someone has a better idea.
    Steve Caponetto - [profile] [e-mail]
    CreedFeed.com - feed your need for Creed!

  4. #4
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't forget to add a unique field for an ID. Also, if you plan on having categories or other grouping, you may want to give that some thought while designing. One idea -
    Code:
    tblRecipes
    recipeID (Primary Key)
    ingrediants
    instructions
    category (Foriegn Key)
    
    tblCategories
    categoryID (Primary Key)
    categoryName
    categoryDesc
    There is one major problem, though! The ingredients field is going to cause problems because it is not normalized. In order to avoid problems, you should set it up with recipes and ingredients being a many to many relationship.
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  5. #5
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Milton Keynes, UK
    Posts
    1,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you was to follow westmich's last point you'd get something like the following structure. It'd make life easier with respect to adding/editing recipes/ingredients and give you greater control as to how you can format the data in the web pages.

    I think that if you're going to use a db then you may as well make the most of it.

    Code:
     
    relation Recipes
    	recipeID
    	recipeName
    	recipeDesc
    	instructions
    	notes
    	category
    	primary key recipeID
    	foreign key category references RecipeCategories
    relation RecipeIngredients
    	recipeID
    	ingredientID
    	quantity
    	measurement
    	primary key (recipeID, ingredientID)
    	foreign key recipeID references Recipes
    	foreign key ingredientID references Ingredients
    	foreign key measurement references Measurements
    relation Ingredients
    	ingredientID
    	ingredientName
    	ingredientDesc
    	primary key ingredientID
    relation Measurements
    	measurementID
    	measurementType
    	primary key measurementID
    relation RecipeCategories
    	categoryID
    	categoryName
    	categoryDesc
    	primary key categoryID
    Shane

  6. #6
    Rusted & Weathered HumanClay's Avatar
    Join Date
    Sep 2000
    Location
    Milwaukee, WI
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that info Shane. Although for my project I have already decided to just do the simple easy way I described in my original post, the info you gave was very helpful. I'm still learning all the indepth stuff with regard to PHP and MySQL.

    Thanks again to shane and westmich for those examples. I'll be using this information for playing around with it to learn more
    Steve Caponetto - [profile] [e-mail]
    CreedFeed.com - feed your need for Creed!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •