Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Sorting Design

 
Ranch Hand
Posts: 431
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose we have an employee database consisting of 10000 records. And, there are REST APIs exposed which return the records in a batch of 500 to the front end and front end will provide the pagination to scroll across those records. Now, if there is a need to implement sorting based on fields individually such as name, id, age etc., then where that sorting will happen - front end or back end? What will be the best design to address this.
 
Saloon Keeper
Posts: 12419
269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sort in the database query if possible. Otherwise do it immediately after you're retrieved records from the database.
 
Vaibhav Gargs
Ranch Hand
Posts: 431
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Stephan. In case, one user sorts based on name, other sorts based on age, and one sorts based on id; then will we sort based on all these different criteria on DB side every time?
 
Stephan van Hulst
Saloon Keeper
Posts: 12419
269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
 
Hoo hoo hoo! Looks like we got a live one! Here, wave this tiny ad at it:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic