Mysql – Hierarchical Structure

MySQL

Every single user has say, 3 of GROUP_A, 10 GROUP_B's per GROUP_A, and 20 GROUP_C's per GROUP_B. And each of the 20 GROUP_C's involve lots of inserts/deletes…

I'm not an expert, but I've done research but it's all theoretical at this point of course, and I don't have hands on experience with the implementation that's for sure. I think my options are something like 'adjacency lists' or 'nested sets'?

Any guidance into the right direction would be very much appreciated!

Best Answer

One way to define your tables:

Users: user_id (primary key), name, etc

Group_A: user_id, group_a_id, group_a_name

Group_B: group_a_id, group_b_id, group_b_name

Group_C: group_b_id, group_c_id, group_c_name

Items: group_c_id, item_id, item_name, details