⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to handle a relation between 3 tables



Hicham
  • profile picture
  • Member

Posted 18 July 2013 - 15:25 PM

Hello,

First Thanks for this awesome tool !

 

I wanna how to handle a relation between 3 tables ?

for example I have :

 

tables:

  • product
  • category
  • sub category

 

relational rules:

  • a category can have 0 or n sub categories
  • a sub category is only part of one category
  • a product can be part of one a sub category (and then it is automatically part of the category of the that sub category)
  • a product can be part of one category (sub category not required)

product(product_id, name,..., category_id, subcategory_id)

category(category_id, name,...)

subcategory(subcategory_id, name,...,category_id)

 

So the problem that I'm facing is on the ADD/Edit forms which is:

the displayed subcategories are not related to the selected category, all subcategories are displayed.

Is there any way to set this rule?

 

Thanks in advance !


Hicham
  • profile picture
  • Member

Posted 18 July 2013 - 16:06 PM

I think this goona do the work for me I'll try it this night !

 

edit: forgot to put the link sorry :) 

/topic/351-autofills-add-fields-on-dropdown-change/

didn't try it yet, when I'll try it I'll post the result here !


redhen_07
  • profile picture
  • Member

Posted 19 July 2013 - 03:41 AM

try this: relation_n_n

 

http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n


davidoster
  • profile picture
  • Member

Posted 19 July 2013 - 08:04 AM

Hello [member=hicham].

Did you check this?


Hicham
  • profile picture
  • Member

Posted 19 July 2013 - 10:14 AM

Hi @redhen_07.

Thanks but that's not what I'm looking for. Thanks anyway :)


Hicham
  • profile picture
  • Member

Posted 19 July 2013 - 10:14 AM

Hi @davidoster.

thanks for the link, I think this is the suitable solution ;)
I'll try it and I'll give you feedback.

Hicham
  • profile picture
  • Member

Posted 20 July 2013 - 11:16 AM

Hi @davidoster.

Thanks a lot it worked for me !