How to enforce unique constraint in MySQL?

Viewed 29797

I have a MySQL table defined:

File
--------------------------
ID int(11) PK
name varchar(100)
customerId int(11) FK
isPrimaryImage tinyint(1)
....


I've read here that MySQL doesn't support a UNIQUE CONSTRAINT with a WHERE condition. For each customerId we'd have only one primaryImage = 1.

So what else can I do to enforce this constraint?

1 Answers
Related