Create Table: CREATE TABLE `category` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`parent` bigint(20) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `parent_idx` (`parent`),
CONSTRAINT `category_parent_category_id` FOREIGN KEY (`parent`) REFERENCES `category` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8
I'm not sure whether a foreign key will imply an index?
EDIT
I don't see the supposed index :
mysql> show index from category;
+----------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+----------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| category | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | |
| category | 0 | name | 1 | name | A | 0 | NULL | NULL | | BTREE | |
| category | 1 | parent_idx | 1 | parent | A | 0 | NULL | NULL | YES | BTREE | |
+----------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
3 rows in set (0.02 sec)