Add categorylinks table to separately list category relationships. Actual
[lhc/web/wiklou.git] / maintenance / tables.sql
1 -- SQL to create the initial tables for the Wikipedia database.
2 -- This is read and executed by the install script; you should
3 -- never have to run it by itself.
4 --
5 -- Indexes should be defined here; please import the rest from indexes.sql.
6
7 CREATE TABLE user (
8 user_id int(5) unsigned NOT NULL auto_increment,
9 user_name varchar(255) binary NOT NULL default '',
10 user_real_name varchar(255) binary NOT NULL default '',
11 user_rights tinyblob NOT NULL default '',
12 user_password tinyblob NOT NULL default '',
13 user_newpassword tinyblob NOT NULL default '',
14 user_email tinytext NOT NULL default '',
15 user_options blob NOT NULL default '',
16 user_touched char(14) binary NOT NULL default '',
17 UNIQUE KEY user_id (user_id)
18 ) PACK_KEYS=1;
19
20 CREATE TABLE user_newtalk (
21 user_id int(5) NOT NULL default '0',
22 user_ip varchar(40) NOT NULL default ''
23 );
24
25 CREATE TABLE cur (
26 cur_id int(8) unsigned NOT NULL auto_increment,
27 cur_namespace tinyint(2) unsigned NOT NULL default '0',
28 cur_title varchar(255) binary NOT NULL default '',
29 cur_text mediumtext NOT NULL default '',
30 cur_comment tinyblob NOT NULL default '',
31 cur_user int(5) unsigned NOT NULL default '0',
32 cur_user_text varchar(255) binary NOT NULL default '',
33 cur_timestamp char(14) binary NOT NULL default '',
34 cur_restrictions tinyblob NOT NULL default '',
35 cur_counter bigint(20) unsigned NOT NULL default '0',
36 cur_is_redirect tinyint(1) unsigned NOT NULL default '0',
37 cur_minor_edit tinyint(1) unsigned NOT NULL default '0',
38 cur_is_new tinyint(1) unsigned NOT NULL default '0',
39 cur_random real unsigned NOT NULL,
40 cur_touched char(14) binary NOT NULL default '',
41 inverse_timestamp char(14) binary NOT NULL default '',
42 UNIQUE KEY cur_id (cur_id)
43 ) PACK_KEYS=1;
44
45 CREATE TABLE old (
46 old_id int(8) unsigned NOT NULL auto_increment,
47 old_namespace tinyint(2) unsigned NOT NULL default '0',
48 old_title varchar(255) binary NOT NULL default '',
49 old_text mediumtext NOT NULL default '',
50 old_comment tinyblob NOT NULL default '',
51 old_user int(5) unsigned NOT NULL default '0',
52 old_user_text varchar(255) binary NOT NULL,
53 old_timestamp char(14) binary NOT NULL default '',
54 old_minor_edit tinyint(1) NOT NULL default '0',
55 old_flags tinyblob NOT NULL default '',
56 inverse_timestamp char(14) binary NOT NULL default '',
57 UNIQUE KEY old_id (old_id)
58 ) PACK_KEYS=1;
59
60 CREATE TABLE archive (
61 ar_namespace tinyint(2) unsigned NOT NULL default '0',
62 ar_title varchar(255) binary NOT NULL default '',
63 ar_text mediumtext NOT NULL default '',
64 ar_comment tinyblob NOT NULL default '',
65 ar_user int(5) unsigned NOT NULL default '0',
66 ar_user_text varchar(255) binary NOT NULL,
67 ar_timestamp char(14) binary NOT NULL default '',
68 ar_minor_edit tinyint(1) NOT NULL default '0',
69 ar_flags tinyblob NOT NULL default ''
70 ) PACK_KEYS=1;
71
72 --
73 -- Track links that do exist
74 -- l_from and l_to key to cur_id
75 --
76 CREATE TABLE links (
77 l_from int(8) unsigned NOT NULL default '0',
78 l_to int(8) unsigned NOT NULL default '0',
79 UNIQUE KEY l_from(l_from,l_to),
80 KEY (l_to)
81 );
82
83 --
84 -- Track links to pages that don't yet exist.
85 -- bl_from keys to cur_id
86 -- bl_to is a text link (namespace:title)
87 --
88 CREATE TABLE brokenlinks (
89 bl_from int(8) unsigned NOT NULL default '0',
90 bl_to varchar(255) binary NOT NULL default '',
91 UNIQUE KEY bl_from(bl_from,bl_to),
92 KEY (bl_to)
93 );
94
95 --
96 -- Track links to images *used inline*
97 -- il_from keys to cur_id, il_to keys to image_name.
98 -- We don't distinguish live from broken links.
99 --
100 CREATE TABLE imagelinks (
101 il_from int(8) unsigned NOT NULL default '0',
102 il_to varchar(255) binary NOT NULL default '',
103 UNIQUE KEY il_from(il_from,il_to),
104 KEY (il_to)
105 );
106
107 --
108 -- Track category inclusions *used inline*
109 -- cl_from keys to cur_id, cl_to keys to cur_title of the category page.
110 -- cl_sortkey is the title of the linking page or an optional override
111 -- cl_timestamp marks when the link was last added
112 --
113 CREATE TABLE categorylinks (
114 cl_from int(8) unsigned NOT NULL default '0',
115 cl_to varchar(255) binary NOT NULL default '',
116 cl_sortkey varchar(255) binary NOT NULL default '',
117 cl_timestamp timestamp NOT NULL,
118 UNIQUE KEY cl_from(cl_from,cl_to),
119 KEY cl_sortkey(cl_to,cl_sortkey(128)),
120 KEY cl_timestamp(cl_to,cl_timestamp)
121 );
122
123 --
124 -- Stores (possibly gzipped) serialized objects with
125 -- cache arrays to reduce database load slurping up
126 -- from links and brokenlinks.
127 --
128 CREATE TABLE linkscc (
129 lcc_pageid INT UNSIGNED NOT NULL UNIQUE KEY,
130 lcc_cacheobj MEDIUMBLOB NOT NULL
131 );
132
133 CREATE TABLE site_stats (
134 ss_row_id int(8) unsigned NOT NULL,
135 ss_total_views bigint(20) unsigned default '0',
136 ss_total_edits bigint(20) unsigned default '0',
137 ss_good_articles bigint(20) unsigned default '0',
138 UNIQUE KEY ss_row_id (ss_row_id)
139 );
140
141 CREATE TABLE hitcounter (
142 hc_id INTEGER UNSIGNED NOT NULL
143 ) TYPE=HEAP MAX_ROWS=25000;
144
145 CREATE TABLE ipblocks (
146 ipb_id int(8) NOT NULL auto_increment,
147 ipb_address varchar(40) binary NOT NULL default '',
148 ipb_user int(8) unsigned NOT NULL default '0',
149 ipb_by int(8) unsigned NOT NULL default '0',
150 ipb_reason tinyblob NOT NULL default '',
151 ipb_timestamp char(14) binary NOT NULL default '',
152 ipb_auto tinyint(1) NOT NULL default '0',
153 ipb_expiry char(14) binary NOT NULL default '',
154 UNIQUE KEY ipb_id (ipb_id)
155 ) PACK_KEYS=1;
156
157 CREATE TABLE image (
158 img_name varchar(255) binary NOT NULL default '',
159 img_size int(8) unsigned NOT NULL default '0',
160 img_description tinyblob NOT NULL default '',
161 img_user int(5) unsigned NOT NULL default '0',
162 img_user_text varchar(255) binary NOT NULL default '',
163 img_timestamp char(14) binary NOT NULL default ''
164 ) PACK_KEYS=1;
165
166 CREATE TABLE oldimage (
167 oi_name varchar(255) binary NOT NULL default '',
168 oi_archive_name varchar(255) binary NOT NULL default '',
169 oi_size int(8) unsigned NOT NULL default 0,
170 oi_description tinyblob NOT NULL default '',
171 oi_user int(5) unsigned NOT NULL default '0',
172 oi_user_text varchar(255) binary NOT NULL default '',
173 oi_timestamp char(14) binary NOT NULL default ''
174 ) PACK_KEYS=1;
175
176 CREATE TABLE recentchanges (
177 rc_timestamp varchar(14) binary NOT NULL default '',
178 rc_cur_time varchar(14) binary NOT NULL default '',
179 rc_user int(10) unsigned NOT NULL default '0',
180 rc_user_text varchar(255) binary NOT NULL default '',
181 rc_namespace tinyint(3) unsigned NOT NULL default '0',
182 rc_title varchar(255) binary NOT NULL default '',
183 rc_comment varchar(255) binary NOT NULL default '',
184 rc_minor tinyint(3) unsigned NOT NULL default '0',
185 rc_bot tinyint(3) unsigned NOT NULL default '0',
186 rc_new tinyint(3) unsigned NOT NULL default '0',
187 rc_cur_id int(10) unsigned NOT NULL default '0',
188 rc_this_oldid int(10) unsigned NOT NULL default '0',
189 rc_last_oldid int(10) unsigned NOT NULL default '0',
190 rc_type tinyint(3) unsigned NOT NULL default '0',
191 rc_moved_to_ns tinyint(3) unsigned NOT NULL default '0',
192 rc_moved_to_title varchar(255) binary NOT NULL default ''
193 ) PACK_KEYS=1;
194
195 CREATE TABLE watchlist (
196 wl_user int(5) unsigned NOT NULL,
197 wl_namespace tinyint(2) unsigned NOT NULL default '0',
198 wl_title varchar(255) binary NOT NULL default '',
199 UNIQUE KEY (wl_user, wl_namespace, wl_title)
200 ) PACK_KEYS=1;
201
202 CREATE TABLE math (
203 math_inputhash varchar(16) NOT NULL,
204 math_outputhash varchar(16) NOT NULL,
205 math_html_conservativeness tinyint(1) NOT NULL,
206 math_html text,
207 math_mathml text,
208 UNIQUE KEY math_inputhash (math_inputhash)
209 );
210
211
212 -- Table searchindex must be MyISAM for fulltext support
213
214 CREATE TABLE searchindex (
215 si_page int(8) unsigned NOT NULL,
216 si_title varchar(255) NOT NULL default '',
217 si_text mediumtext NOT NULL default '',
218 UNIQUE KEY (si_page)
219 ) PACK_KEYS=1;
220
221 CREATE TABLE interwiki (
222 iw_prefix char(32) NOT NULL,
223 iw_url char(127) NOT NULL,
224 iw_local BOOL NOT NULL,
225 UNIQUE KEY iw_prefix (iw_prefix)
226 );
227
228 -- Used for caching expensive grouped queries
229 CREATE TABLE querycache (
230 qc_type char(32) NOT NULL,
231 qc_value int(5) unsigned NOT NULL default '0',
232 qc_namespace tinyint(2) unsigned NOT NULL default '0',
233 qc_title char(255) binary NOT NULL default '',
234 KEY (qc_type,qc_value)
235 );
236
237 -- For a few generic cache operations if not using Memcached
238 CREATE TABLE objectcache (
239 keyname char(255) binary not null default '',
240 value mediumblob,
241 exptime datetime,
242 unique key (keyname),
243 key (exptime)
244 );