Posted 05 May 2006 - 09:43 AM
you have Categories of recipes,
and final Recipes, so nothing complicated..
some categories do not have subcategories, only recipes that belong to them..
so i know you relate categories to subcategories as one to many, and subcategories to recipes as one to many or many to many (as one recipe may exist in more than one subcategory) and that's all ok..
but HOW TO relate now categories that do not have subcategories to recipes table..when in recipes table is needed field from subcategories (enforce referential integrity)..
thank you very much
Posted 05 May 2006 - 07:51 PM
Posted 06 May 2006 - 10:47 AM
That's the wrong way to think about it -- you only need two tables, recipes & categories. That relationship is simple; then, simply store a parent_category_id in the categories table, and have the top-level ones have a NULL parent. That's it.
yes ,but then you would have repeating parent_category_id field values for all recipes that belong to same category, and that way it would be hard to maintain database in future..
Posted 06 May 2006 - 01:44 PM
yes ,but then you would have repeating parent_category_id field values for all recipes that belong to same category, and that way it would be hard to maintain database in future.. [/quote]
Yes, you would have repeating parent_category_id field values - but how does that make it hard to maintain your database? That's actually very standard database design...
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users