April 22nd, 2013, 02:56 PM
One to many Relationships - HELP!
Let me prefix this by saying that I'm retired, 72 years old, ex-Computer Engineer, programmed in VB and Delphi, but NEVER worked with one to many relationships, because I never needed to for the work I did.
Now I'm trying to get my head around One to many Relationships, but going quietly crazy. I'm trying to create these Tables at Runtime in Delphi. I've done this lots of times, but never had to set up relationships, but if I have the SQL or the Table Structure, I can program it.
I've tried using MySQL Workbench. A great Tool IF you know what you are trying to do (and I don't!)
Here are my Tables - it's pretty obvious what I'm trying to do, can someone PLEASE give me the SQL to create this along with the relationships? save me from bashing my head against a brick wall. (The Workbench complete diagram would also do. I think)
PRIMARY KEY iType (TypeID),
UNIQUE INDEX iName (Name)
Thanks in advance
April 22nd, 2013, 03:24 PM
So this RecipeIngredients table is to list the ingredients that a recipe uses, right? That means it needs to mention both the recipe and ingredient. You've got something for the ingredient in there now but nothing for the recipe, so add another column for the recipe ID.
And actually what you're doing is a many-many relationship. Maybe that helps with some of the confusion? A particular recipe can have many ingredients, and a particular ingredient can be used in many recipes. Many, many.
April 22nd, 2013, 04:00 PM