Search code examples
phpmysqlhierarchical-datanested-sets

Hierarchical data - Parent id or Nested set model


I'm working on a project that required categories, I used a nested set model and it worked out well. I have another portion of the same project, however it requires a different type of hierarchy, there will only ever be a parent. So, an item can only EVER relate to one other item.

Would you say for this, using simply parent_id would be more appropriate then a full nested set model?

Thank you!


Solution

  • I would say it doesn't matter. I think of nested set and adjacent tree model as different data structure but the same type of hierarchical tree. I think of a ternary trie and a patricia trie. Both have a different data structure but the type trie is the same.