Manual:Categorylinks table

The categorylinks table stores entries on a page of the type, which places the page into the category "abc" (for which an associated page may or may not exist). Links of the form category:abc are not stored in categorylinks, but are handled as normal links. The editable parts of category pages are stored like other pages.

"DESCRIBE categorylinks" results in this:


 * cl_from stores the page_id of the article where the link was placed.
 * cl_to stores the name (excluding namespace prefix) of the desired category.
 * cl_sortkey stores the title by which the page should be sorted in a category list.
 * cl_timestamp stores the time at which that link was last updated in the table.

There are three indexes which help improve performance:
 * The concatenation of cl_from and cl_to (for when an article is edited)
 * The concatenation of cl_to and the first 128 bytes of cl_sortkey (for displaying articles in order)
 * The concatenation of cl_to and cl_timestamp

On MediaWiki 1.8alpha, DESCRIBE categorylinks gives the following result: +--+-+--+-+---+---+ +--+-+--+-+---+---+ +--+-+--+-+---+---+
 * Field       | Type            | Null | Key | Default           | Extra |
 * cl_from     | int(8) unsigned | NO   | PRI | 0                 |       |
 * cl_to       | varchar(255)    | NO   | PRI | NULL              |       |
 * cl_sortkey  | varchar(86)     | NO   |     | NULL              |       |
 * cl_timestamp | timestamp      | YES  |     | CURRENT_TIMESTAMP |       |

+--+-+--+-+---+---+ +--+-+--+-+---+---+ +--+-+--+-+---+---+
 * Field       | Type            | Null | Key | Default           | Extra |
 * cl_from     | int(8) unsigned | NO   | PRI | 0                 |       |
 * cl_to       | varchar(255)    | NO   | PRI | NULL              |       |
 * cl_sortkey  | varchar(86)     | NO   |     | NULL              |       |
 * cl_timestamp | timestamp      | YES  |     | CURRENT_TIMESTAMP |       |

+--+-+--+-+---+---+ +--+-+--+-+---+---+ +--+-+--+-+---+---+
 * Field       | Type            | Null | Key | Default           | Extra |
 * cl_from     | int(10) unsigned| NO   | PRI | 0                 |       |
 * cl_to       | varchar(255)    | NO   | PRI | NULL              |       |
 * cl_sortkey  | varchar(70)     | NO   |     | NULL              |       |
 * cl_timestamp | timestamp      | YES  |     | CURRENT_TIMESTAMP |       |

+--+-+--+-+---+---+ +--+-+--+-+---+---+ +--+-+--+-+---+---+
 * Field       | Type            | Null | Key | Default           | Extra |
 * cl_from     | int(8) unsigned | NO   | PRI | 0                 |       |
 * cl_to       | varchar(255)    | NO   | PRI | NULL              |       |
 * cl_sortkey  | varchar(86)     | NO   |     | NULL              |       |
 * cl_timestamp | timestamp      | NO   |     | CURRENT_TIMESTAMP |       |