By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
CREATE TABLE
CREATE TABLE
INSERT 0 2
INSERT 0 2
INSERT 0 2
ERROR: insert or update on table "c" violates foreign key constraint "fk_simple_and_safe_solution" DETAIL: Key (a_id, b_id)=(2, 1) is not present in table "b".