Manual:Categorylinks table

The categorylinks table stores entries corresponding to links of the form   or  , which when placed anywhere on a page places that page into the url>Help:Categories|category named Title (for which an associated page may or may not exist).

Links beginning with a colon, like  , are not stored in the categorylinks table, but are handled as normal url>Help:Links|internal links (in this case leading to the page Category:Title).

The editable parts of category pages are stored like other pages.

There are four indexes which help improve performance:
 * The concatenation of cl_from and <tvar|of2>cl_to</> (for when an article is edited)
 * The concatenation of <tvar|of1>cl_to</>, <tvar|of2>cl_type</>, <tvar|of3>cl_sortkey</>, and <tvar|of4>cl_from</> (for showing articles in order)
 * The concatenation of <tvar|of1>cl_to</> and <tvar|of2>cl_timestamp</>
 * cl_collation

cl_from
Stores the page>Manual:page table</>|page.pageid>Manual:Page_table#page_id</>|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. This is the binary sortkey, that depending on url>manual:$wgCategoryCollation</>|$wgCategoryCollation may or may not be readable by a human (but should sort in correct order when comparing as a byte string)

cl_timestamp
Stores the time at which that link was last updated in the table.

cl_sortkey_prefix
This is either the empty string if a page is using the default sortkey (aka the sortkey is unspecified). Otherwise it is the human readable version of cl_sortkey. Needed mostly so that cl_sortkey can be easily updated in certain situations without re-parsing the entire page.

cl_collation
What collation is in use. Used so that if the url1>manual:$wgCategoryCollation</>|collation changes, the url2>manual:updateCollation.php</>|updateCollation.php script knows what rows need to be fixed in db.

cl_type
What type of page is this (<tvar|file> </>, <tvar|subcat> </> (subcategory) or <tvar|page> </> (normal page)). Used so that the different sections on a category page can be paged independently in an efficient manner.

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

+--+--+--+-+---+-+ +--+--+--+-+---+-+ +--+--+--+-+---+-+
 * 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 |

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

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