aspose file tools*
The moose likes JForum and the fly likes Why there are both index and key in some cases? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JForum
Bookmark "Why there are both index and key in some cases?" Watch "Why there are both index and key in some cases?" New topic
Author

Why there are both index and key in some cases?

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
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

Joined: Apr 22, 2012
Posts: 17424
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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why there are both index and key in some cases?