In a one-to-many table setup say customer to phone. Where one customer can have many phones.
The table for phone has a column is_primary so that the applications knows which one to use under normal circumstances. There can only be one is_primay that is true and n that can be false.
Is there any constraint in MySQL that can be applied to enforce the above scenario? The application currently protects against this but we wanted to add a block at the db.
A unique constraint does not allow for the n number of false phone. It would make is so only 1 true and 1 false per customer.
There is the idea of a partial unique constraint but I cannot find docs in MySQL for this just postgres.