Find Shared Links Still Served After Their Expiration
Last updated: November 29, 2026
Quick Overview
Using a shared_links table and a link_access_events table, report for each enterprise how many accesses were served after the link's expires_at, how many links were affected, and the latest such access.
Box
November 29, 20260
0
0 solved
Using a shared_links table and a link_access_events table, report for each enterprise how many accesses were served after the link's expires_at, how many links were affected, and the latest such access.
Shared links with expiry dates are a core Box security control, and enterprise admins expect an expired link to stop working at once. A data screen uses this to see whether you can turn a security invariant into an audit query, filter on the right outcome column, and handle NULL expiry correctly.
What the Interviewer Expects
- Joins events to links on link_id and compares accessed_at to expires_at
- Excludes links with no expiry rather than treating NULL as expired
- Counts only served outcomes, not denied ones
- Groups by enterprise and reports both hits and distinct links
- Mentions time zone consistency between the two timestamps
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you turn this into a daily data-quality alert without scanning all history?
- Expiry can be edited after creation. How does that change the query?
- How would you tell a real enforcement bug apart from clock skew between services?
- Which index or partitioning would make this cheap on billions of access events?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
shared_links(link_id, enterprise_id, item_id, expires_at) with expires_at NULL meaning no expiry. link_access_events(link_id, accessed_at, outcome) where outcome is something like served, `den...
Approach
An access violates the policy when the link had an expiry, the request was served, and it happened strictly after the expiry. Filter on those three conditions after an inner join, then aggregate per e...