Ok, so I got a chance to look over some of the examples of the many-to-
many relationship in jobeet and askeet and I still have a question.
The many-to-many relationship described in those places makes perfect
sense to me if there aren't any other variables associated with each
item.

But since you input quantities (in differing units of measurement in
my case) along with ingredients I'm wondering if you wouldn't set up a
three tables:

Recipes
Ingredients
ingredientsUsedInRecipes (not a real table name :P )

Where Recipes would have foreign keys to ingredientsUsedInRecipes and
ingredientsUsedInRecipes would have foreign keys to Ingredients which
would have the actual name of the ingredient and any other information
about it that doesn't change.

First, is this the best way to set this up (I'm kinda hoping it's
not!)? Second, is there an easy way to accomplish this (updating 2
tables) from one form in Symfony?

Thanks again.

On Aug 23, 5:53 pm, Daniel Lohse <[email protected]> wrote:
> You are going to model this as a many-to-many relation between a (one) Recipe 
> and its (many) Ingredients where each Recipe can have an infinite number of 
> ingredients and one ingredient can belong to an infinite number of recipes. 
> :) You'll find a description of how to do many-to-many relationships in the 
> Jobeet tutorial. Hopefully this makes more sense when you do read it.
>
> PS: Yes, you could also model this as a one-to-many relation between Recipe 
> and Ingredient but then the ingredient "milk" would be duplicated over and 
> over again (because the ingredient would save the ID of the recipe it belongs 
> to and can hence only save one parent (recipe)) and could not have attributes 
> of its own that could be changed independently of the recipes. That would 
> lead so serious duplication.
>
> Hope that helps,
> Daniel
>
> On 23.08.2010, at 23:44,json2001wrote:
>
>
>
> > I'm very new to symfony, in fact I'm still reading the gentle intro
> > and working through Jobeet, and this question is probably very simple
> > (I hope!) as I image this comes up all the time.
>
> > Users will be creating recipes. I would like to keep another table of
> > ingredients for autocompletion on the Create Recipe form.
>
> > Clearly, not all recipes have the same number of ingredients and I
> > can't imagine having a recipe table that has ingredient_id_1,
> > ingredient_id_2, ingredient_id_3, etc! So, how can I store an
> > arbitrary number of ingredients to a single field- "ingredient_ids."
> > Is there a way to store an array? Or is it typical to just use a coma
> > separated listing and parse it in the model?
>
> > Thanks.Really just looking for best practice sorts of advice at this
> > point so I can start to wrap my head around the method.
>
> > --
> > If you want to report a vulnerability issue on symfony, please send it to 
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to