Access and evidence policies · Original fictional data · Free files and full answers
Accept approvals only from independently authorized reviewers
At day10 an approval is valid only when requester differs from approver, and the approver inherits a live allow for that resource without a matching deny. Return approval_id,approver sorted approval_id. Public permissions also count.
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 day10 an approval is valid only when requester differs from approver, and the approver inherits a live allow for that resource without a matching deny. Return approval_id,approver sorted approval_id. Public permissions also count.
- 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 approval_id, approver. 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 day10 an approval is valid only when requester differs from approver, and the approver inherits a live allow for that resource without a matching deny. Return approval_id,approver sorted approval_id. Public permissions also count.
- For the first output record, approval_id = 2; approver = bob.
- Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.
Watch for this wrong turn
A different person is independent but may still lack authority to approve that resource.
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 RECURSIVE m(user,principal) AS (SELECT approver,approver FROM approvals UNION SELECT m.user,g.parent FROM m JOIN members g ON g.member=m.principal) SELECT a.id approval_id,a.approver FROM approvals a WHERE requester<>approver AND EXISTS(SELECT 1 FROM grants g WHERE g.resource=a.resource AND g.effect='allow' AND g.expires>10 AND (g.principal='public' OR EXISTS(SELECT 1 FROM m WHERE m.user=a.approver AND m.principal=g.principal))) AND NOT EXISTS(SELECT 1 FROM grants g WHERE g.resource=a.resource AND g.effect='deny' AND g.expires>10 AND EXISTS(SELECT 1 FROM m WHERE m.user=a.approver AND m.principal=g.principal)) ORDER BY a.id;
"approval_id","approver" "2","bob"Reference SQL · Complete expected CSV · Empty answer CSV
Choose another SQL task · Original data exception cases · Larger workplace projects