Im creating a HTBTM relation like:
Dressess
id
name
Dressess_Styles
开发者_JAVA百科
id
dress_id
style_id
Styles
id
name
Now i need the every Dresses_Styles also can Has and Belongs to Many Colors.
My question:
Some light and considerations on how do I create this relationships without breaking CakePHP standard.
Please tell me what you think about this:
Colors_Dressess_Styles
id
dress_style_id
color_id
Colors
id
name
It is the correct way or exist a better one?
Thanks.
Looks good to me.
Dresses belongs to Dresses_Styles
Styles belongs to Dresses_Styles
Dresses_Styles HABTM Colors
It's just my rule of thumb, but when I need to to actually create HABTM model (to add methods, relationships, etc.), it usually means that it is a separate model by itself. Does Dresses_Styles represent any entity here?
精彩评论