I need to add a constraint to a table x which has many to one relation to other table. So the table x has field other_table_id.
There is other column in table x called primary which is boolean type.
I want to make sure that there is none or only one primary=true per one other_table_id.
Multiple rows can have other_table_id equals some same value and primary=false but only one true per other_table_id.
How do I create this constraint?