[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pagination, get N elements from a set



Hi,

I am modelling an existing piece of code. The code runs paginated SQL queries that I would like to model. In particular, I model the Database as a set of identifiers that satisfy

  Database \in SUBSET 1..N_IDENTIFIERS

Given page size PAGE_SIZE and page number P, I would like to retrieve elements from the Database that are in range between PAGE_SIZE*P and PAGE_SIZE*(P+1) of the sequence of sorted identifiers. For example, if Database is {1,2,5,6,7,10,11} , PAGE_SIZE=3, then the query for page P=0 should result in {1,2,5}, page P=1 gives {6,7,10} and P=2 gives {11}.

How to model such "query"?