0

I have table say - T with columns as <a,b,c>. <A,B> is the primary key of the table. Now I need to put a constraint on relationship A->C such that for an a there can be multiple rows with c as 0, but only one row as 1.

I understand that we can put simple constraint in mysql such as - don't add column with specific values(CHECK constraint in MySQL is not working). but I am not able to find a way to put such a complex constraint. Do I need to denormalize the table? or do I need to put a check in the code for the sanity check?.

Mangat Rai Modi
  • 5,397
  • 8
  • 45
  • 75

0 Answers0