I am developing a java application which will be graphically depicting and organizing hundreds of objects. Each of these objects is loaded in from a SQL database, for use in this program.
The user sorts this data, in order to gain information about the dataset, i (as the programmer) have come across three distinct methods to accomplish this:
- Use individual SQL queries to return pre-sorted data to the program.
- Use a sorting algorithm locally to sort the entire dataset.
- Use a local SQLite database to copy the entire dataset to, then query the local database for sorting instead.
Which would be preferable, or are there any other solutions I may have missed?
In general all of the solutions may work, it depends on the concrete requirements – my thoughts:
1. Use individual SQL queries to return pre-sorted data to the program
Works well if the user defines sorting criteria upfront. What if she wants to resort after data retrieval (leads to #2)? It may make sense to define a default sort for each request or a parameter influencing the sort sequence based on certain criteria like user role.
2. Use a sorting algorithm locally to sort the entire dataset
As outlined before, a combination of #1 and #2 may be what you need.
3. Use a local SQLite database to copy the entire dataset to, then query the local database for sorting instead
Totally different strategy, several things you have to care about:
Personal option: I’d go with a combination of #1 and #2. Furthermore, I’d try to define the interface in a way that supports scrolling (e.g. “retrieve rows #20-100”).
Not a definite answer, but my opinion based on the facts you provided…