I have this table and constraints:
table_ttt ( id1, -- UNIQUE CONSTRAINT WHERE id1_ref IS NULL AND id2_ref IS NULL id2, id1_ref, -- FOREIGN KEY (id1_ref