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.

Fields

 * cl_from : Stores the page.page_id of the article where the link was placed.
 * cl_to : Stores the name (excluding namespace prefix) of the desired category. Spaces are replaced by underscores (_)
 * 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

Versions
+---+--+--+-+---+-+ +---+--+--+-+---+-+ +---+--+--+-+---+-+
 * Field            | Type                         | Null | Key | Default           | Extra                       |
 * cl_from          | int(10) unsigned             | NO   | PRI | 0                 |                             |
 * cl_to            | varbinary(255)               | NO   | PRI |                   |                             |
 * cl_sortkey       | varbinary(70)                | NO   |     |                   |                             |
 * cl_timestamp     | timestamp                    | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
 * cl_sortkey_prefix | varbinary(255)              | NO   |     |                   |                             |
 * cl_collation     | tinyint(4)                   | NO   | MUL | 0                 |                             |
 * cl_type          | enum('page','subcat','file') | NO   |     | page              |                             |

+--+-+--+-+---+---+ +--+-+--+-+---+---+ +--+-+--+-+---+---+
 * 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      | 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(255)    | NO   |     | NULL              |       |
 * cl_timestamp | timestamp      | YES  |     | CURRENT_TIMESTAMP |       |