How would you paginate an editable table whose records change during browsing?
Understand the idea, explain it in your own words and use the rubric to find your next learning gap.
The idea behind the question
Stable cursor pagination needs a deterministic ordering and a tie-breaker, but its guarantees also depend on how concurrent inserts and updates affect that ordering.
Many records share the same created time; sorting only by that value can skip or repeat records across page boundaries.
// In-memory fixed snapshot only; a real API validates its cursor and ownership.
const rows = [{ time: 10, id: 2 }, { time: 9, id: 3 }, { time: 10, id: 1 }];
const ordered = [...rows].sort((a, b) => a.time - b.time || a.id - b.id);
const cursor = { time: 10, id: 1 };
const next = ordered.filter(r => r.time > cursor.time || (r.time === cursor.time && r.id > cursor.id));
console.log(JSON.stringify(ordered.map(r => r.id)));
console.log(JSON.stringify(next.map(r => r.id)));Show expected output
[3,1,2]
[2]Copy and paste to run in a separate tab. This example illustrates one concept; it is not a complete application or an automatically graded task.
A practical way to learn it
Design a cursor for records ordered by created time and ID. Walk through tied timestamps and an edit that moves a row, stating the user-visible policy.
Open PostgreSQL compilerThe related tool opens separately; your interview answer stays here. Written practice is self-guided, without automatic code grading.
Build an explanation you understand
- State what the concept does in plain language.
- Apply it to the example and make your assumptions explicit.
- Explain a trade-off, failure case and how you would test it.
- Distinguish your actual experience from a proposed approach.
How would you explain it?
Single-question timers reset on refresh. Full mock sessions can resume from this browser.
Strengthen your explanation
Compare reasoning, not identical wording. Reference answers describe a possible approach; replace hypothetical statements with truthful details from your own work.
One way to answer
I would clarify whether browsing needs a consistent snapshot or may reflect live changes. I would define a stable total order, such as creation time plus unique ID, and have the server validate the cursor and authorization for every page. Updates that change sort keys require an explicit policy because a record can move between pages. On the client I would retain selection by record ID, handle deleted rows and avoid implying that the loaded page contains the entire dataset. Tests should cover tied keys, empty pages, concurrent changes and returning after an edit.
What a strong explanation should cover
Tick only the points your own answer addresses. This is self-assessment, not AI scoring.
0 / 3 points self-reportedWatch out for
- Assuming cursor pagination automatically prevents all skips during concurrent edits.
Now go one level deeper
- When would an immutable snapshot token be needed?
- How should select-all work when only one page is loaded?
Further reading
Further-reading links support learning; the reference is Sukoaa-authored, not an official employer answer key.