Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Scenario: 1 main_product belongs to 1 sub_products (perfect).
I have 1 sub_product that belongs to mutliple main_products (problem -> cartesian product)
I have a main_products table:
main_products table | |
category | product |
c1 | p1 |
c2 | p2 |
c1 | p3 |
c2 | p3 |
I have a sub_products Table:
sub_products table | |||
sub cateogry | product | main | Number of Sales Items |
sc1 | p1 | A | 1 |
sc2 | p2 | A | 2 |
sc3 | p3 | A | 2 |
After left join I see 4 entries:
new_table | ||||
category | product | sub cateogry | main | Number of Sales Items |
c1 | p1 | sc1 | A | 1 |
c2 | p2 | sc2 | A | 2 |
c1 | p3 | sc3 | A | 2 |
c2 | p3 | sc3 | A | 2 |
Now, I have a CFile to check the product availability. The key is "category + sub_category + main" in between "new_table" and "Cfile Applymap"
Cfile Applymap | ||
category | sub category | main |
c1 | sc1 | A |
c2 | sc2 | A |
After Applymap I still see 4 rows because it is true due to all the conditions for the sub_product availability meets.
Now the problem is I see p3 = 4 (sum of items) which should be 2. But It is coming due to cartesian product.
How to solve this problem?
Thanks
what if you don't join your product tables? Just keep them as tables in your datamodel.
Without the join you won't get the troubled by the cartesian product.
The problem is main_products table "category".
I need this field to check the CFile whether the sub itme meets the criteria or not?
The ideal solution should be:
new_table | ||||
category | product | sub cateogry | main | Number of Sales Items |
c1 | p1 | sc1 | A | 1 |
c2 | p2 | sc2 | A | 2 |
c1; c2 | p3 | sc3 | A | 2 |
Hi @Vegar,
Any help?