100 likes | 110 Views
Learn about pagination, caching, sorting, searching, and browsing in databases and web applications. Explore examples and techniques for efficient data retrieval and display.
E N D
CS122B: Projects in Databases and Web Applications Winter 2019 Professor Chen Li Department of Computer Science UC Irvine Notes 05: Pagination,Caching, Sort, Search, Browse
Pagination • Showresultsindifferentpages
SQLSupport SELECT columns FROM table LIMIT 20 OFFSET 10
EmbeddingparametersinGETrequests Example: https://www.autotrader.com/cars-for-sale/Sedan/Irvine+CA-92604?zip=92604&startYear=1981&numRecords=25&sortBy=derivedpriceDESC&vehicleStyleCodes=SEDAN&firstRecord=0&endYear=2019&searchRadius=10
Caching in Tomcat • Storethequeryresultsasanobject • Laterrequestscanbeservedusingthecachewithoutqueryingthedatabase
Caching in Tomcat • Pros: • LesstrafficonDB • Lowresponsetime • Cons: • Memoryoverheadinwebserver • Resultsmaybeobsolete
Different queries • Browsing: SELECT * FROM Movies, genres, genres_in_movies WHERE genres.name = “action” • Searching: SELECT * FROM Movies WHERE title LIKE “%term%”;
Same page of movie list • Implement a Java Servlet program by taking a SQL query as a parameter • Show the results of the query as a list of movies.
Sorting • Frontend GET request includes a sorting parameter such as “DESC” and “ASCE”; • Use “ORDER BY” in SQL to sort the results