The MySQL Syntax for Adding a Foreign Key in the Alter Table Command is as follows:
ADD [CONSTRAINT [symbol]] FOREIGN KEY [index_name] (index_col_name,...)
What is the difference between the CONSTRAINT symbol and the index_name. From what I can make out, they are both methods of naming a Foreign Key, but I figure there must be more differences that that, can anyone enlighten me?
The [symbol] is a constraint name, if it is specified, MySQL will create foreign key and index named as [symbol]; in this case [index_name] is ignored.
The second one [index_name] is index name. This index is created automatically. If [symbol] is omitted, the foreign key will be named by server, and index will be named as [index_name].