Manual:Database layout

The current schema for any version - with copious comments - can be found in the maintenance/tables.sql file. See the latest version from SVN.

Proposed schema changes page contains the discussion for possible improvements to the database schema.

MediaWiki 1.10
Version 1.10 introduces the following tables:
 * Page restrictions table

MediaWiki 1.9
Version 1.9 uses the following tables:
 * archive table
 * categorylinks table
 * externallinks table
 * filearchive table
 * hitcounter table
 * image table
 * imagelinks table
 * interwiki table
 * ipblocks table
 * job table
 * langlinks table
 * logging table
 * math table
 * objectcache table
 * oldimage table
 * page table
 * pagelinks table
 * querycache table
 * querycachetwo table
 * querycache info table - new
 * recentchanges table
 * redirect table - new
 * revision table
 * searchindex table
 * site_stats table
 * templatelinks table
 * text table
 * trackbacks table
 * transcache table
 * user table
 * user_groups table
 * user_newtalk table
 * watchlist table

MediaWiki 1.8
Version 1.8 uses the following tables:
 * archive table
 * categorylinks table
 * externallinks table
 * filearchive table - new
 * hitcounter table
 * image table
 * imagelinks table
 * interwiki table
 * ipblocks table
 * job table
 * langlinks table - new
 * logging table
 * math table
 * objectcache table
 * oldimage table
 * page table
 * pagelinks table
 * querycache table
 * querycache info table - new
 * recentchanges table
 * revision table
 * searchindex table
 * site_stats table
 * templatelinks table
 * text table
 * trackbacks table
 * transcache table - new
 * user table
 * user_groups table
 * user_newtalk table
 * watchlist table

MediaWiki 1.6-1.7
Version 1.6 uses the following tables :
 * archive table
 * categorylinks table
 * externallinks table - new
 * hitcounter table
 * image table
 * imagelinks table
 * interwiki table
 * ipblocks table
 * job table - new
 * logging table
 * math table
 * objectcache table
 * oldimage table
 * page table
 * pagelinks table
 * querycache table
 * recentchanges table
 * revision table
 * searchindex table
 * site_stats table
 * templatelinks table - new
 * text table
 * trackbacks table
 * user table
 * user_groups table
 * user_newtalk table
 * validate table
 * watchlist table

Tables in version 1.7 are different than in 1.6. Eg. user_table has no column user_rights. If you want to set privileges to user in mediawiki 1.7, you should go for user_groups table.

MediaWiki 1.5
Version 1.5 uses the following tables :
 * archive table
 * categorylinks table
 * hitcounter table
 * image table
 * imagelinks table
 * interwiki table
 * ipblocks table
 * logging table - new
 * math table
 * objectcache table
 * oldimage table
 * page table - new
 * pagelinks table - new
 * querycache table
 * recentchanges table
 * revision table - new
 * searchindex table
 * site_stats table
 * text table
 * trackbacks table - new
 * user table
 * user_groups table - new
 * user_newtalk table
 * validate table - new
 * watchlist table

MediaWiki 1.4
Version 1.4 uses the following tables:
 * archive table - "deleted" pages
 * blobs table
 * brokenlinks table - links in internal link style to non-existing pages in the same project (see below)
 * categorylinks table
 * cur table - current pages
 * hitcounter table
 * image table
 * imagelinks table tracks usage of images in wikipages (see below)
 * interwiki table
 * ipblocks table
 * links table - links in internal link style to existing pages in the same project (see below)
 * linkscc table - (see below)
 * math table
 * objectcache table
 * old table - old versions of pages
 * oldimage table
 * querycache table
 * recentchanges table
 * searchindex table
 * site_stats table
 * testac table
 * text table
 * user table
 * user_newtalk table
 * watchlist table

Data types
Data types used:
 * blob (binary) types :
 * tinyblob <= 255 bytes
 * blob <= 65,535 bytes
 * longblob <= 16,777,215 bytes
 * char(14), varchar(255)
 * numbers :
 * tinyint(1) unsigned
 * int(8) unsigned
 * int(11)
 * double unsigned

Explanation of the link tables
There are presently three link tables: links, brokenlinks and imagelinks. There are a couple of uses for these tables:
 * enables "What links here" and "Related changes" to work, looking at incoming or outgoing links
 * provides the list of pages that use an image shown on an image's description page
 * allows making reports of pages that aren't linked (Orphans, Unused images) or are linked to but don't exist (Most wanted pages)
 * slightly speed up page rendering by avoiding individual checks for the existence of each linked page to determine how to render its  link

In MediaWiki versions <=1.4 there was also a 'linkscc' table which cached data from the other three tables. This was used only for speeding rendering.

Maintenance of link tables
If you import data to the cur table and don't rebuild the links, you won't be able to use "What links here", "Related changes", "Orphans", etc. If you don't want to, well I suppose that's okay... (Brion Vibber)