If I create a foreign key constraint for table 'photos' in phpmyadmin, I later see that the constraint is named 'photos_ibfk_1', and the next constraint is called 'photos_ibfk_2', etc. From this I have gathered that [tablename]_ibfk_constraintIndex is the convention for DB constraints in MySQL. Is this correct? What does IBFK stand for?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
innodb foreign key. It's just short hand naming convention. You could call it asdfqwerty and the name would still work.
Although foreign key names can be anything, it's actually a good practice to follow the convention of putting the table name first.
The most important reason for this is that foreign key names must be globally unique (contrarily to index names). So, by following this convention, foreign key names only have to be unique within each table.
Personally, I use the convention
In order to name your foreign keys, you will have to explicitly spell out the constraint on the table, instead of just the foreign key.
Simple method (automatic naming, will result in
Explicit method (will result in