Practice ยท 1 of 3
Foreign-Key Enforcer
Write insertWithFK(tables, table, row) โ tables is { users: Set of ids, tasks: [] }; the tasks table's authorId must exist in users. Valid insert => append and return { ok: true, id } (ids are "t<n>" incrementing); FK violation => { ok: false, error: "fk-violation" } and nothing inserted.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Schema Design โ Practice