I am using phpMyAdmin. In order to set up a foreign key constraint with InnoDB (under the "Relation View" link on the Structure tab) it appears that I need to add an index for the field to which I want to add the restraint. This obviously has an impact on performance of inserts/updates on the table, particularly if there are several constraints I want to add. Is it possible to specify a foreign key constraint or relational integrity in InnoDB without the need to create an Index for the required field?
Many thanks JS, London
From the MySQL reference manual:
a foreign key contraint refers 1 key to another one. A foreign key is also an index.
So yes you need to index collumn (either with unique or with foreign key) to use them in a foreign key constraint.
There's 3 types of indexes available:
- primary key
- unique index
- non-unique index