Handling Calculations and Sorting in API vs in iOS Application

This is a design question with the answer probably being determined by what is computationally more effecient. Sorry if this has been answered in the book directly or indirectly, but I have not seen an answer to my question from the headings of the other chapters or from Section I.

I have a pivot which handles a user liking a, we’ll say acronym. I want to sort the acronyms by the number of likes it has. I can set up a column for the acronyms with the number of likes and hit this table each time the pivot table relating to it is populated. I can also just get all the likes from the pivot table for a given acronym and sort from within the application. I think the second option seems better and more likely to be best practice, but I wanted clarification.

Regards.

With SQL databases, having a single source of truth is the best option. So use the pivot to get the likes. You can also probably use the database to do the sorting for you as well

1 Like