I am developing a social media type site. I have begun initial design and ran into potential issues. The site revolves around components, sub-components, and sub-sub-components. It has a hierarchy structure. I initially created a table for components, a table for sub-components, and a table for sub-sub-components. These tables are linked by ids. This would work fine, I believe, for most things. but...
I was wanting users to be able to "like" or "follow" certain components, sub-components, and sub-sub-components. I was thinking I would have to create a "like" table or "interaction" table. I had no single id to link. If a user would like a sub-sub-component I would have to list the component_id, the sub-component_id, and the sub-sub-component_id. This seems to be a pain.
So why not have 1 table of Elements or just Components. Sub-component1 and sub-component2 are the children of Component1. sub-sub-component1 is the child of sub-component2 etc.
In doing this I could create unique component_ids whether the component is a sub-component, or a sub-sub-component and I could apply those id's in my likes table.
Does this seem like a more efficient process? I have created the single table with parent_ids and such and have now run into problems with querying this table to produce data. How do I go about showing components, the child of the component (as sub-component), and the child of the sub component (as sub-sub-component)?
I hope this gives you an idea of what I am looking for. Please let me know if you need more information.