It's impossible. The unique restriction on id_1 and id_2 will force each row to have a different (unique) combination of id_1 and id_2 . This is the exact opposite of what you are describing.
You can fulfill your requirement with a trigger, but given the small amount of information you provide, I cannot say if this was the best solution.
A component foreign key can also be a solution, but I donβt know what id_1 and id_2 , so itβs very difficult to say.
source share