HACKER Q&A
📣 ssss11

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?


  👤 bradley13 Accepted Answer ✓
Homework question? Even if it's not, you need a much better problem description, before anyone could help you. I have the feeling you don't really understand the problem yourself.

👤 jpmarionata
Use one of the BI tools. They'll do this mapping for you as part of their ETL

👤 pestatije
the relationships you mention are just product properties...you relate different products that have the same property with the use of a query