Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why there are both index and key in some cases?

 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all.

Can some one explain to me why in the schema we have both index and key for the same column, for example, in table jforum_forums, we have:
-----------------------------------------------------------------------
CREATE TABLE jforum_forums (
forum_id INT NOT NULL auto_increment,
categories_id INT NOT NULL default '1',
forum_name varchar(150) NOT NULL default '',
forum_desc varchar(255) default NULL,
forum_order INT default '1',
forum_topics INT NOT NULL default '0',
forum_last_post_id INT NOT NULL default '0',
moderated TINYINT(1) DEFAULT '0',
PRIMARY KEY (forum_id),
KEY (categories_id),
INDEX idx_forums_cats (categories_id)
) TYPE=InnoDB;
-------------------------------------------------------------------
We have key and index for categories_id, and they actually are all for index. Can some one explain why we have both of them?

Thank you very much.


David

[originally posted on jforum.net by davidxia]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably historical inertia... e.g., the original create script from table code added it and it never got cleaned up.
[originally posted on jforum.net by monroe]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic