I am working on a database model for an ecommerce project. Very simply put, we have products, which need categorisation - done this 1000 times before.
Except this time, we have decided to use Nested Sets as a structure for categorisation. In all honesty, I agree with this method, as it describes a parent/child/sibling heirarchy very well (IMHO).
However, here is where I am stumbling...
Each product can exist in more than one category. OK, maybe that's not true... It may be better to state that each category may have more than one parent.
Example:
One product range we sell is DJ lighting. Let's take the example of a bulb for a moonflower light.
This wants to be within the categorisation DJ Equipment / Lighting / Bulbs / {specific product}
BUT
We also want to categorise it as Accessories / Bulbs / {specific product}
I have a products table, with an "ID", etc per product.
I have a categories table with an "ID", "Name" per category.
I have a product_categorisation table with a "ProductID", "CategoryID" with a one-to-many mapping.
So this allows a product to be in many categories. So not only on our back-end we can multi-categories a product, but we can utilise this for searches and navigation.
My thought is this... A category_heirarchy table, using nested sets, with an "ID" (for internal table purpose), "lft", "rgt" and "CategoryID" (mapping to the categories table).
Am I over-complicating things? Do I need a product to fit into multiple categories, or categories to fit to multiple parents: eg. Does the category of Bulbs need to appear twice in the heirarchy - with the product under each / or does a pointer to bulbs appear twice in the heirarchy, bulbs only exist once as a category, and the product link to that category?
Yeah, no doubt! I loved when gaming magazines shipped with the latest and greatest demos! I still have many including Quake 1 demo way back when. Kinda like PC boxes with thick manuals, instructions, etc.
Sony has had some misses but honestly the one thing they have done well is not compromise (too much) on first party titles! Microsoft on the other hand have left first party IPs to rot in hell. The who conversation about "entertainment" we want to be the best entertainment company tells you everything you need to know. They are love bombing initially but then doing a Don Mattrick rug pull where XBOX becomes and entertainment company as oppose to a gaming one. All the fan service over the last 3 months down the pan. This company should never have been allowed to acquire so many studios only to kill them off!
Did Labour lose big? They had losses there is no doubt. However let's look at the reality. The conservatives have 168 councils I believe. Labour have 113 and Reform...38. That's a lot of growth for Reform granted. But that is not a wipeout, Reform don't have the majoring in fact at 76 I believe the Liberal Democrats have nearly twice the councils Reform do. So I am thinking there is a lot more noise than signal going on here.
Now then let's talk about the law. It's an age restriction. We do it for cigarettes, **** and alcohol. This idea that some kids will find there way around it so it's not worth even trying is really really sad.
Hell we can't stop every murder. Should we stop trying there too? That is the logical conclusion.
Question
+Nik Louch Subscriber²
I am working on a database model for an ecommerce project. Very simply put, we have products, which need categorisation - done this 1000 times before.
Except this time, we have decided to use Nested Sets as a structure for categorisation. In all honesty, I agree with this method, as it describes a parent/child/sibling heirarchy very well (IMHO).
However, here is where I am stumbling...
Each product can exist in more than one category. OK, maybe that's not true... It may be better to state that each category may have more than one parent.
Example:
One product range we sell is DJ lighting. Let's take the example of a bulb for a moonflower light.
This wants to be within the categorisation DJ Equipment / Lighting / Bulbs / {specific product}
BUT
We also want to categorise it as Accessories / Bulbs / {specific product}
I have a products table, with an "ID", etc per product.
I have a categories table with an "ID", "Name" per category.
I have a product_categorisation table with a "ProductID", "CategoryID" with a one-to-many mapping.
So this allows a product to be in many categories. So not only on our back-end we can multi-categories a product, but we can utilise this for searches and navigation.
My thought is this... A category_heirarchy table, using nested sets, with an "ID" (for internal table purpose), "lft", "rgt" and "CategoryID" (mapping to the categories table).
Am I over-complicating things? Do I need a product to fit into multiple categories, or categories to fit to multiple parents: eg. Does the category of Bulbs need to appear twice in the heirarchy - with the product under each / or does a pointer to bulbs appear twice in the heirarchy, bulbs only exist once as a category, and the product link to that category?
Hah, sorry if this is really noob!
Link to comment
https://www.neowin.net/forum/topic/842336-database-nested-sets-product-multi-categorisation/Share on other sites
2 answers to this question
Recommended Posts