By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE INDEX
| team_id | remaining_time | description | difficulty |
|---|---|---|---|
| 1 | 1 | ||
| 2 | 1 | ||
| 3 | 1 | ||
| 4 | 1 | ||
| 5 | 1 |
INSERT 0 5
| pers_id | full_name |
|---|---|
| 1 | Jon |
| 2 | Mai |
| 3 | Dan |
| 4 | Bill |
INSERT 0 4
| team_id | pers_id | level | slot | pos |
|---|---|---|---|---|
| 1 | 1 | 1 | l | 1 |
| 1 | 2 | 1 | m | 2 |
| 1 | 3 | 1 | m | 3 |
| 2 | 1 | 1 | l | 1 |
| 2 | 3 | 1 | m | 2 |
| 2 | 2 | 1 | m | 3 |
| 3 | 2 | 1 | l | 1 |
| 3 | 3 | 1 | m | 2 |
| 3 | 1 | 1 | m | 3 |
| 4 | 2 | 1 | l | 1 |
| 4 | 3 | 1 | m | 2 |
INSERT 0 11
| team_id | lead | m1 | m2 |
|---|---|---|---|
| 1 | 1 | 2 | 3 |
| 3 | 2 | 1 | 3 |
SELECT 2
| team_id | lead | m1 | m2 |
|---|---|---|---|
| 1 | 1 | 2 | 3 |
| 2 | 1 | 2 | 3 |
SELECT 2
ERROR: duplicate key value violates unique constraint "team_member_pkey" DETAIL: Key (team_id, pers_id)=(4, 3) already exists.
ERROR: duplicate key value violates unique constraint "uni_team_slot_pos" DETAIL: Key (slot, pos, team_id)=(l, 1, 4) already exists.
ERROR: new row for relation "team_member" violates check constraint "chk_1lead_2member" DETAIL: Failing row contains (4, 4, 1, m, 1).
ERROR: new row for relation "team_member" violates check constraint "chk_1lead_2member" DETAIL: Failing row contains (5, 4, 1, l, 2).
ERROR: insert or update on table "team_member" violates foreign key constraint "team_member_pers_id_fkey" DETAIL: Key (pers_id)=(7) is not present in table "person".
ERROR: insert or update on table "team_member" violates foreign key constraint "team_member_team_id_fkey" DETAIL: Key (team_id)=(7) is not present in table "team".
ERROR: duplicate key value violates unique constraint "uni_team_slot_pos" DETAIL: Key (slot, pos, team_id)=(m, 2, 1) already exists.