Resending because for some reason my 2nd message appeared and this one is
not in the list yet. :-(

The recursive refers to whether or not you want sub_categories to have other
sub_categories...

Products belong to categories, so I suggested a separate category table to
handle that relationship,
Then sub categories are related to a category of course, but you have a
HABTM relationship with the product.

It could be all done with a recursive category table, but it would
complicate the cake relationships. Especially when you start traversing deep
into sub-sub-categories...

So I suggested that you have 
Product.cat_id -> category.id
Product.id
   <-( product_sub_categories.prod_id
         Product_sub_categories.sub_cat_id
   )-> 
sub_category.id

then you can have
sub_category.cat_id -> category.id
and
sub_category.parent_id -> sub_category.id

and you are very-happy-super-tree-enabled!

:-)

Cheers,
Dave

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of [email protected]
Sent: 2009-06-04 11:57
To: CakePHP
Subject: Re: A little help needed on determining my model relation ships
please


Ok I think I follow, just to clarify:

A product will belong to at least one or more subcategories, so i
guess it will be

product_sub_categories
  id
  product_id
  sub_category_id

Im not too sure what you mean by the recursive parent_id.. can you
please elaborate?

Thanks

Kevin

On Jun 4, 3:02 pm, "David Coleman" <[email protected]> wrote:
> This depends on how you want to build your sub categories tree:
>
> Is it a relationship like this:
>
> category
>
>   id
>
>   parent_id
>
> or
>
> category
>
>   id
>
> sub_category
>
>   id
>
>   category_id
>
>   parent_sub_category
>
> your product could be
>
> product
>
>   id
>
>   ...
>
> Then a join table
>
> categories_products
>
>   id
>
>   product_id
>
>   category_id
>
> or you could have
>
> product
>
>   id
>
>   category_id
>
> product_sub_categories
>
>   id
>
>   product_id
>
>   sub_category_id
>
> it really depends on what your data model requirements are.
>
> The join table will be extremely useful in establishing the HABTM
> relationships you require.
>
> Cake bake will not automatically detect recursive parent_id as a category.
> so you will have to define that manually.
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
Behalf
>
> Of Beedge
> Sent: 2009-06-04 10:46
> To: CakePHP
> Subject: A little help needed on determining my model relation ships
please
>
> Hi all, about to start on my first cake project. A straight forward e-
>
> commerce site.
>
> I am not used to having to visualise my database relationships so I
>
> was hoping for a little help.
>
> A product belongs in a category
>
> A product can be in many categories
>
> A Category has Sub categories
>
> Is this just a HABTM relationship between products and categories?
>
> I will be using tree behavior for my categories.
>
> Any comments on this or helpers?  I would love to find a tutorial that
>
> covered this, but all I can really find is blog tutorials!
>
> Thanks in advance
>
> Kev
>
>
>
>  image001.gif
> < 1KViewDownload


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to