Monday, June 1, 2009

Re: Database and Model Design for HABTM

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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: