Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL - Unique foreign key

I have to make one of the foreign keys unique. The problem is, I am getting the following message from the phpMyAdmin:

The following indexes appear to be equal and one of them should be removed: consignmentnumber_id_UNIQUE, fk_consignments_consignmentnumbers2

So my question is this: should I be bothered? Is it really important not to have such indexes?

like image 321
Cleankod Avatar asked Mar 15 '11 13:03

Cleankod


1 Answers

For the future, if you want to make your foreign key unique, you can simply modify your foreign key column like this:

ALTER TABLE your_table
MODIFY COLUMN your_fk_column [INT, VARCHAR etc.][NOT NULL] UNIQUE;
like image 76
guzoff Avatar answered Oct 04 '22 16:10

guzoff