Core of the wiki: each page has an entry here which identifies it by title and contains some essential metadata.


Inter-table Relationships

edit


MySQL Table Description

edit
mysql> desc mw_page;
+-------------------+---------------------+------+-----+---------+----------------+
| Field             | Type                | Null | Key | Default | Extra          |
+-------------------+---------------------+------+-----+---------+----------------+
| page_id           | int(8) unsigned     |      | PRI | NULL    | auto_increment |
| page_namespace    | int(11)             |      | MUL | 0       |                |
| page_title        | varchar(255)        |      |     |         |                |
| page_restrictions | tinyblob            |      |     |         |                |
| page_counter      | bigint(20) unsigned |      |     | 0       |                |
| page_is_redirect  | tinyint(1) unsigned |      |     | 0       |                |
| page_is_new       | tinyint(1) unsigned |      |     | 0       |                |
| page_random       | double unsigned     |      | MUL | 0       |                |
| page_touched      | varchar(14)         |      |     |         |                |
| page_latest       | int(8) unsigned     |      |     | 0       |                |
| page_len          | int(8) unsigned     |      | MUL | 0       |                |
+-------------------+---------------------+------+-----+---------+----------------+
11 rows in set


Annotated Table Creation Code

edit
-- Core of the wiki: each page has an entry here which identifies
-- it by title and contains some essential metadata.

CREATE TABLE /*$wgDBprefix*/page (

  -- Unique identifier number. The page_id will be preserved across
  -- edits and rename operations, but not deletions and recreations.

  page_id             int(8)         unsigned     NOT NULL  auto_increment,
  
  -- A page name is broken into a namespace and a title.
  -- The namespace keys are UI-language-independent constants,
  -- defined in includes/Defines.php.

  page_namespace      int                         NOT NULL,
  
  -- The rest of the title, as text.
  -- Spaces are transformed into underscores in title storage.

  page_title          varchar(255)   binary       NOT NULL,
  
  -- Comma-separated set of permission keys,
  -- indicating who can move or edit the page.

  page_restrictions   tinyblob                    NOT NULL  default '',
  
  -- Number of times this page has been viewed.

  page_counter        bigint(20)     unsigned     NOT NULL  default '0',
  
  -- 1 indicates that the article is a redirect.

  page_is_redirect    tinyint(1)     unsigned     NOT NULL  default '0',
  
  -- 1 indicates this is a new entry, with only one edit.
  -- Not all pages with one edit are new pages.

  page_is_new         tinyint(1)     unsigned     NOT NULL  default '0',
  
  -- Random value between 0 and 1, used for Special:Randompage

  page_random         real           unsigned     NOT NULL,
  
  -- This timestamp is updated whenever the page changes in
  -- a way requiring it to be re-rendered, invalidating caches.
  -- Aside from editing, this includes permission changes,
  -- creation or deletion of linked pages, and alteration
  -- of contained templates.

  page_touched        char(14)       binary       NOT NULL  default '',

  -- Handy key to revision.rev_id of the current revision.
  -- This may be 0 during page creation, but that shouldn't
  -- happen outside of a transaction... hopefully.

  page_latest         int(8)         unsigned     NOT NULL,
  
  -- Uncompressed length, in bytes, of the page's current source text.

  page_len            int(8)         unsigned     NOT NULL,

PRIMARY KEY           page_id (page_id),
UNIQUE INDEX          name_title (page_namespace, page_title),
  
  -- Special-purpose indexes

INDEX                 (page_random),
INDEX                 (page_len)

) ENGINE=InnoDB;