ID #1123

I have Foreign Keys and they work but there are a lot of weird names ...


To create a Foreign Key/relationship in MySQL you (or SQLyog) must send a CREATE TABLE or ALTER TABLE SQL-statement like

alter table ´Test´.´TableName´ add constraint ´ConstraintName´ foreign key(´numfield´) references ´TableName2´ (´id´);

In case the constraint name is not explicitly specified MySQL generates it automatically. That is also true for some of the indexes and their names with recent MySQL versions.

As a result the table definition can become very hard to read and understand because of all the weird names occurring in the table definition when Foreign Keys are used extensively.

SQLyog offers you the option to specify index names and constraint names that are clear and logical. To specify an index name go to 'manage indexes' and the option to specify a constraint name is available from 'manage Foreign keys'. Both are conveniently available from the table context menu.

Tags: -

Related entries:

You can comment this FAQ