0

while working on osCommerce-3 i got the table structure for category & categories_description as

CREATE TABLE IF NOT EXISTS `osc_categories` (
  `categories_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `categories_image` varchar(255) DEFAULT NULL,
  `parent_id` int(10) unsigned DEFAULT NULL,
  `sort_order` int(11) DEFAULT NULL,
  `date_added` datetime DEFAULT NULL,
  `last_modified` datetime DEFAULT NULL,
  PRIMARY KEY (`categories_id`),
  KEY `idx_categories_parent_id` (`parent_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; 

CREATE TABLE IF NOT EXISTS `osc_categories_description` (
  `categories_id` int(10) unsigned NOT NULL,
  `language_id` int(10) unsigned NOT NULL,
  `categories_name` varchar(255) NOT NULL,
  PRIMARY KEY (`categories_id`,`language_id`),
  KEY `idx_categories_desc_categories_id` (`categories_id`),
  KEY `idx_categories_desc_language_id` (`language_id`),
  KEY `idx_categories_desc_categories_name` (`categories_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

here i am not getting the meanning of indexing

"idx_categories_desc_categories_id",

"idx_categories_desc_language_id",

"idx_categories_desc_categories_name"

What is the use of this indexing.What does it mean?

Community
  • 1
  • 1
Sumant
  • 954
  • 1
  • 18
  • 39
  • possible duplicate of [MySQL KEY/UNIQUE KEY](http://stackoverflow.com/questions/8742575/mysql-key-unique-key) – random Apr 03 '12 at 22:24
  • 1
    No; it's not a duplicate of that question. The OP wanted to understand the osCommerce index naming convention; that's all. – Scott C Wilson Apr 04 '12 at 19:16
  • If it's a case as to why osCommerce chose certain names, this would be off topic/not constructive. If it was asking why they are set up that way, it would be a duplicate. On either case, since there's all this guessing with no clarification, it's not a real question @sco – random Apr 05 '12 at 22:09

2 Answers2

1

The three tokens you mentioned

"idx_categories_desc_categories_id",

"idx_categories_desc_language_id",

"idx_categories_desc_categories_name"

are just names - there's nothing special about them. They could have been called "foo", "bar" and "baz" and that would have been just fine.

They keep to the osCommerce naming convention of using idx_ for indexes, then the name of the table then the key field. But that's just a developer's convention; it's not required by the database.

Scott C Wilson
  • 19,102
  • 10
  • 61
  • 83
1

These three indices are created for the tables specified in the brackets (categories_id, language_id, categories_name). The KEY keyword is a synonym for the INDEX keyword. It is no special magic behind it.

I guess these three indexes are used to speed up data retrival/sorting operations on these tables.

The index "idx_categories_desc_categories_id" is by the way redundant, "categories_id" already covered by left part of the composite index on the primary key.

Flo Doe
  • 5,197
  • 2
  • 19
  • 18