• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why there are both index and key in some cases?

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic