Modeling A Food Recipes Database

  • I'm trying to design a "recipe box" database and I'm having trouble getting it right. I have no idea if I'm on the right track or not, but here's what I have.

    recipes(recipeID, etc.)

    ingredient(ingredientID, etc.)

    recipeIngredient(recipeID, ingredientID, amount)

    category(categoryID, name)

    recipeCategory(recipeID, categoryID, etc.)

    So I have a couple of questions.

    * How am I doing so far? Is this design okay from what you all know?

    * How would I implement the preparation steps? Should I create an additional many-to-many implementation (something like preparation(prepID, etc.) and recipePrep(recipeID, prepID)) or just add the directions in the recipes table? I would like this to be an ordered list in the UI (webpage).

    Thank you for your help.

  • Follow simple rule for data modelling:-

    Identify the attributes(columns in tables) from project SOW.

    Identyfing relationships among these attributes.

    If you have one-2-one relationship then club all these attributes in single entity called db table.

    If we have one to many relationship then use Primary forgien key relationship.

    If we have many-2-many relationship then use junction tables.

    I hope this would help you.

  • So I have a couple of questions.

    * How am I doing so far? Is this design okay from what you all know?

    It looks pretty good. I would suggest using a proprietary product like MS Visio 2010 to model your project however with either ERM or UML. I know it's a bit 'Ivory Tower' but it's good practice to use some kind of visual aid to help model the entire thing. Some people tend to use a 'just go for it' approach and make alterations later, and that is fine if you already kinda know what you are doing.

    * How would I implement the preparation steps? Should I create an additional many-to-many implementation (something like preparation(prepID, etc.) and recipePrep(recipeID, prepID)) or just add the directions in the recipes table? I would like this to be an ordered list in the UI (webpage).

    You really want to avoid M:N relationships like the plague. They can plague your database with redundancies, and give you out put errors. This can also let to an enourmous amount of work just trying to 'normalize' the dern thing. If you happen to come across a M:N then simply use a 'Bridge Entity' (associative entity) to get you back to a 1:M situation.

    As 'Grasshopper' just said, make sure you use 'Foreign Keys' to keep referential integrity between your relations.

    Hope that helps.

  • That does help and thank you very much.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply