Access and evidence policies · Original fictional data · Free files and full answers
Warn when a currently valid direct grant expires before the next request
At day0 consider direct user allow grants with expires>0. For each find the first same-principal/resource request on or after day0. Return grant_id,next_request_day,expires if next request is at or after expiry. Sort grant_id.
Use this fixed business case to build a checked CSV and a replayable SQL handoff. No account required. Scenario datasets are shared across related exercises; each exercise has its own decision and output contract.
Your output contract
- At day0 consider direct user allow grants with expires>0. For each find the first same-principal/resource request on or after day0. Return grant_id,next_request_day,expires if next request is at or after expiry. Sort grant_id.
- Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero.
- These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ.
Return columns exactly as grant_id, next_request_day, expires. Sort order follows the task. Output has 1 rows; an empty CSV field means NULL.
Source data
grants
10 source rows · Download grants CSV
| id INTEGER | principal TEXT | resource TEXT | effect TEXT | expires INTEGER | mask INTEGER |
|---|---|---|---|---|---|
| 1 | alice | docs | allow | 20 | 1 |
| 2 | team | docs | allow | 50 | 2 |
| 3 | alice | secret | deny | 50 | 3 |
| 4 | team | secret | allow | 50 | 1 |
| 5 | bob | docs | allow | 5 | 0 |
| 6 | reviewer | finance | allow | 50 | 2 |
| 7 | public | open | allow | 50 | 0 |
| 8 | team | old | allow | 8 | 1 |
| 9 | alice | finance | allow | 50 | 1 |
| 10 | alice | archive | allow | 50 | 1 |
members
3 source rows · Download members CSV
| member TEXT | parent TEXT |
|---|---|
| alice | team |
| bob | team |
| team | reviewer |
requests
8 source rows · Download requests CSV
| id INTEGER | user TEXT | resource TEXT | day INTEGER |
|---|---|---|---|
| 1 | alice | docs | 10 |
| 2 | alice | secret | 10 |
| 3 | bob | docs | 10 |
| 4 | bob | finance | 10 |
| 5 | alice | old | 10 |
| 6 | outsider | open | 10 |
| 7 | outsider | docs | 10 |
| 8 | alice | finance | 10 |
approvals
4 source rows · Download approvals CSV
| id INTEGER | requester TEXT | approver TEXT | resource TEXT |
|---|---|---|---|
| 1 | alice | alice | finance |
| 2 | alice | bob | finance |
| 3 | bob | outsider | docs |
| 4 | bob | alice | secret |
Field dictionary and schema
grants: id INTEGER — Stable source record identifier; not a row position. principal TEXT — Literal business key or category label. Match exactly and retain NULL where present. resource TEXT — Literal business key or category label. Match exactly and retain NULL where present. effect TEXT — Permission outcome, allow or deny. expires INTEGER — Expiry boundary; the goal declares whether equality is eligible. mask INTEGER — Privacy mask level; higher values require stricter masking. members: member TEXT — Literal business key or category label. Match exactly and retain NULL where present. parent TEXT — Immediate parent identifier, or NULL for a hierarchy root. requests: id INTEGER — Stable source record identifier; not a row position. user TEXT — Literal business key or category label. Match exactly and retain NULL where present. resource TEXT — Literal business key or category label. Match exactly and retain NULL where present. day INTEGER — Integer day index, or ISO YYYY-MM-DD date when stored as text; the task declares cutoff semantics. approvals: id INTEGER — Stable source record identifier; not a row position. requester TEXT — Literal business key or category label. Match exactly and retain NULL where present. approver TEXT — Literal business key or category label. Match exactly and retain NULL where present. resource TEXT — Literal business key or category label. Match exactly and retain NULL where present.
A method you can reuse
- At day0 consider direct user allow grants with expires>0. For each find the first same-principal/resource request on or after day0. Return grant_id,next_request_day,expires if next request is at or after expiry. Sort grant_id.
- For the first output record, grant_id = 5; next_request_day = 10; expires = 5.
- Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.
Watch for this wrong turn
Looking only at grant validity today misses a predictable credential expiry before the next scheduled access.
Run and check in SQLite
Your SQL runs locally in the existing SQLite worker. The checker compares every column, row, type, value and row order with this fixed output. It accepts equivalent SELECT or WITH queries. Browser storage keeps your SQL on this device when available.
Complete worked SQL and expected output
WITH x AS (SELECT g.id,g.expires,MIN(r.day) next_request_day FROM grants g JOIN requests r ON r.user=g.principal AND r.resource=g.resource AND r.day>=0 WHERE g.effect='allow' AND g.expires>0 GROUP BY g.id) SELECT id grant_id,next_request_day,expires FROM x WHERE next_request_day>=expires ORDER BY id;
"grant_id","next_request_day","expires" "5","10","5"Reference SQL · Complete expected CSV · Empty answer CSV
Choose another SQL task · Original data exception cases · Larger workplace projects