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?
2
Answers
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 theINDEX
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.
The three tokens you mentioned
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.