User:RichMorin/mw externallinks

From Meta, a Wikimedia project coordination wiki

Track links to external URLs.


Inter-table Relationships[edit]

  • el_from - page ID ( page.page_id)


MySQL Table Description[edit]

mysql> desc mw_externallinks;
+--------------+-----------------+------+-----+-------------------+-------+
| Field        | Type            | Null | Key | Default           | Extra |
+--------------+-----------------+------+-----+-------------------+-------+
| el_from      | int(8) unsigned |      | PRI | 0                 |       |
| el_to        | blob            |      |     |                   |       |
| el_index     | blob            |      |     |                   |       |
+--------------+-----------------+------+-----+-------------------+-------+
3 rows in set

Annotated Table Creation Code[edit]

-- Track links to external URLs.

CREATE TABLE /*$wgDBprefix*/externallinks (

  -- Key to page_id of the referring page.

  el_from             int(8)         unsigned     NOT NULL  default '0',
  
  -- The URL

  el_to               blob                        NOT NULL  default '',
  
  -- In the case of HTTP URLs, this is the URL with any username
  -- or password removed, and with the labels in the hostname reversed
  -- and converted to lower case. An extra dot is added to allow for
  -- matching of either example.com or *.example.com in a single scan.
  --
  -- Example:
  --      http://user:password@sub.example.com/page.html
  --   becomes
  --      http://com.example.sub./page.html
  --
  -- which allows for fast searching for all pages under example.com
  -- with the clause:
  --      WHERE el_index LIKE 'http://com.example.%'

  el_index            blob                        NOT NULL  default '',
  
  -- This isn't really used at present. Provided for an optional
  -- sorting method by approximate addition time.

  cl_timestamp        timestamp                   NOT NULL,
  
  KEY                 (el_from, el_to(40)),
  KEY                 (el_to(60), el_from),
  KEY                 (el_index(60))

) ENGINE=InnoDB;