А вы знаете что если в mysql сделать комбинированный уникальный ключ в котором одно из полей может быть null, то в случае если это поле будет null этот самый комбинированный уникальный ключ не будет работать:
null,value1, value2 null,value1, value2
При этом это не баг:
In MySQL, a UNIQUE index is one in which all values in the index must be distinct. An error occurs if you try to add a new row with a key that matches an existing row. The exception to this is that if a column in the index is allowed to contain NULL values, it can contain multiple NULL values. This exception does not apply to BDB tables, for which an indexed column allows only a single NULL.
При этом если сделать select distinct(value1) from table
и в этой таблице будет несколько строк с value1=null
то оно работает вполне ожидаемо: null будет показан и будет показан только один раз.
Но так-то с mysql всё хорошо. Только что про внешний ключ можно забыть, но кому эта ересь то нужна.
2015.12.14 00:57