What I’m trying to do:
In DataTables, create the following relationship efficiently to add, search, and delete topics. Topics follow a tree hierarchy, in that, each topic node can have many child nodes, and each topic node can have only one parent topic node.
A User has a collection of Customers.
A Customer can be subscribed to any sort of topics in a Topic Hierarchy, which belongs to only one User.
How this might be represented to the user would be something like this, where topics are visually represented as a hierarchy of checkboxes, so if you want to subscribe to the topic called “Dairy Promotions” as a customer, you are automatically subscribed to the topics “Cheese Promotion” and “Milk” promotions.
What I’m thinking of doing
Method 1, Big table for all users: Create a “Topics” table, with the topic name, payload, child_topics, and parent_topic.
When adding a new topic, a topic hierarchy will be constructed from querying the Topics table, so it’s only looking for the topics for the current user.
Method 2, Table per user: Create a Topics_For_User_XYZ per user, structured the same way ( with the topic name, payload, child_topics, and parent_topic, etc…) and then somehow lookup and create the topic hierarchy that way
I’m sure I’m not the only one who has run into this type of problem, that is, how to represent hierarchical data unique to each user for an app.