Best practices when dealing with Helper DB tables

Posted 1 year ago by mknooihuisen

I've occasionally found situations in which I've needed a sort of helper table with the sole purpose of controlling interactions with the data in another table. A quick example:

I have a Tasks Eloquent model which is displayed to my users as the standard unordered list, but with drag and drop functionality. I want my users to be able to reorder the tasks by priority and save the result, so I created a second (helper) table to store the ordered Task IDs. Note that this is not a voting system, each person's priority list is saved as its own entry in the helper table, just because.

In this system and others like it, the helper table has no functionality, I only need to read it to determine how to display my Task objects. Is it best practice to create an empty Eloquent Model class for this, or to use the Query Builder? Or is there a third option I may not know about?

Thanks in advance, Mike

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