Categorylinks table

From MediaWiki.org

Jump to: navigation, search
Manual:Contents MediaWiki database layout Categorylinks table


The categorylinks table stores entries on a page of the type [[category:abc]], 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.

MediaWiki version: 1.14

DESCRIBE categorylinks;

+--------------+-----------------+------+-----+-------------------+-------+
| 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       | NO   |     | CURRENT_TIMESTAMP |       |
+--------------+-----------------+------+-----+-------------------+-------+

[edit] Fields

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

[edit] Previous versions

MediaWiki version: 1.8
+--------------+-----------------+------+-----+-------------------+-------+
| 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 |       |
+--------------+-----------------+------+-----+-------------------+-------+


MediaWiki version: 1.9
+--------------+-----------------+------+-----+-------------------+-------+
| 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 |       |
+--------------+-----------------+------+-----+-------------------+-------+


MediaWiki version: 1.11
+--------------+-----------------+------+-----+-------------------+-------+
| 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 |       |
+--------------+-----------------+------+-----+-------------------+-------+


MediaWiki version: 1.12
+--------------+-----------------+------+-----+-------------------+-------+
| 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 |       |
+--------------+-----------------+------+-----+-------------------+-------+


Personal tools