3ll0

Pivot or Polymorphism?

Posted 3 years ago by 3ll0

I am working on a side-project which has 4 kinds of Tools/Widgets, each has Calls and Views. All Calls and Views contain the same data for about 80%.

The other 20% are data that differs between each tool which is why I am working with pivot tables at the moment. Meaning I store the 80% that is shared data in the Calls and Views and the other 20% go into the tool_one_calls for example.

This works fine and keeps everything neat and clean but I thought about polymorphism which would remove the *_calls and *_views tables. The problem I then see is that there are like 3-4 empty columns in most cases since the columns from tools_two,_three,_four would be empty if the Model saved would be a tool_one.

So would Pivot tables or using Polymorphism be the right choice for this case?


The table names at the moment.

tool_one
tool_two
tool_tree
tool_four

calls
tool_one_calls
tool_two_calls
tool_tree_calls
tool_four_calls

views
tool_one_views
tool_two_views
tool_tree_views
tool_four_views

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.