My one santims (Latvia) :) You can do as you suggest yourself, but also move the HABTM relationship away from the recipes.
Category -> HABTM -> Category : which makes it possible for one subcategory to appear under more than one main category. And even more subsubcategories under subcategories, if it ever should be necessary! Category -> hasMany -> Recipe Recipe -> belongsTo -> Category. Thus you will have the following tables: categories recipes categories_categories Enjoy, John On Jun 1, 12:26 pm, Luke <eik...@hotmail.com> wrote: > Hi, > > Thanks for your answers. Actually, if I look at the first one, I do > understand that the way I am doing it right now, I would have > duplications in my db tables. > maincategories and subcategories will be filled manually, > recipes_subcategories and recipes will be filled through the "Add > recipe" Form. > > F.e. > > maincategories (id, maincategory_name) > 1 | Main Dish > 2 | Appetizer > 3 | BBQ > > subcategories (id, subcategory_name, maincategory_id) > 1 | Beef | 1 > 2 | Beef | 3 > 3 | Pork |1 > 4 | Vegtarian | 2 > > recipes_subcategories (id,recipe_id) > 1 | 1 | 1 > 2 | 1 | 2 > > recipes (id, Name) > 1| Beef Chops > > I can't see how I could otherwise design the tables. 1 maincategory > has many subcategories, 1 recipes can belong to many main/ > subcategories, but I am thinking that if i use the subcategory_id for > the recipe, that this subcategory is already bind to a maincategory, > so I wont have to add this into the recipes_subcategories. > > Does this makes sense? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---