Ask HN: Data Structure Question
I have a database of products and need to map their relationships. I’m looking for suggestions on the best approach, thanks!
Each product has multiple types of relationship to other products such as by size (100mL, 500mL, 1L etc), or by colour, or by flavour (e.g. salt & vinegar or original crisps), or simply by being the “same” product but by competing manufacturers.
If each product row contains a list of related products as a field, that could work, but wouldn’t it be better to map out the tree, graph (or whichever data structure) of all products’ relationships and when a product is queried search the data structure and return the list for that product?
5 comments
[ 2.8 ms ] story [ 28.0 ms ] thread