User:RichMorin/mw templatelinks

From Meta, a Wikimedia project coordination wiki

Track template inclusions.


Inter-table Relationships[edit]

  • tl_from - page ID ( page.page_id)
  • tl_namespace - page namespace ( page.page_namespace)
  • tl_title - page title ( page.page_title)


MySQL Table Description[edit]

mysql> desc mw_templatelinks;
+--------------+-----------------+------+-----+---------+-------+
| Field        | Type            | Null | Key | Default | Extra |
+--------------+-----------------+------+-----+---------+-------+
| tl_from      | int(8) unsigned |      | PRI | 0       |       |
| tl_namespace | int(11)         |      | PRI | 0       |       |
| tl_title     | varchar(255)    |      | PRI |         |       |
+--------------+-----------------+------+-----+---------+-------+
3 rows in set


Annotated Table Creation Code[edit]

-- Track template inclusions.

CREATE TABLE /*$wgDBprefix*/templatelinks (

  -- Key to the page_id of the page containing the link.

  tl_from             int(8)         unsigned     NOT NULL  default '0',
  
  -- Key to page_namespace/page_title of the target page.
  -- The target page may or may not exist, and due to renames
  -- and deletions, may refer to different page records
  -- as time goes by.

  tl_namespace        int                         NOT NULL  default '0',
  tl_title            varchar(255)   binary       NOT NULL  default '',
  
UNIQUE KEY            tl_from(tl_from, tl_namespace, tl_title),
KEY                   (tl_namespace, tl_title)

) ENGINE=InnoDB;