Hi,

I am still a Cake newbie, but maybe someone give me a hint on my
issue. I am trying to learn cake by developing a recipe site.

There are Maincategories and Subcategories.
F.e.

BBQ -> (Pork, Beef, Vegetarian)
Main Dish -> (Vegetarian....)

A recipe can belong to different Categories, so a "Steak" could show
up under "BBQ" and "Main Dish" and there under Beef.

I'm planing to have a Form which reads out the Maincategories from the
DB and when you click on a checkbox, the subcategories should show up
(AJAX Request?)

I have been thinking about the DB Design now for a while and thought I
first had a solution. Than I got doubts and re-designed the tables and
the models. I am now rather confused if this design is correct and
would hope that someone could give some feedback. Okay, here the
tables:
===================
maincategories *** this table is filled manually
- id
- maincategory
===================
subcategories *** this table is filled manually
- id
- subcategory
- maincategory_id
===================
recipes_subcategories ** this will be filled in when Add Recipe Form
was send off
- id
- subcategory_id
- recipe_id
===================
recipes ** this will be filled in when Add Recipe Form was send off
- id
- recipename
===================


My Models:

====== Recipe Model
=======================================================
class Recipe extends AppModel {
           var $name = 'Recipe';
           var $belongsTo = array(
                                            'User' => array(
                                                          'className'
=> 'User'
                                                           )
                                            );

           var $hasAndBelongsToMany = array(
                                                        'Subcategory'
=>
 
array(
 
'className' => 'Subcategory',
 
'joinTable' => 'recipes_subcategories',
 
'foreignKey' => 'recipe_id',
 
'associationForeignKey' => 'subcategory_id'
                                                                                
     )
                                                                 );

============================================================================

====== Subcategory Model
=======================================================
 class Subcategory extends AppModel {
            var $name = 'Subcategory';
            var $belongsTo = array('Maincategory');
            var $hasAndBelongsToMany = array(
 
'Recipe' =>
 
array(
 
'className' => 'Recipe',
 
'joinTable' => 'recipes_subcategories',
 
'foreignKey' => 'subcategory_id',
 
'associationForeignKey' => 'recipe_id'
                                                                                
    )
                                                                );
}


Is this setup correct or any advice how it should look instead? Thanks
a lot in advance.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to