r98148 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98147‎ | r98148 | r98149 >
Date:17:59, 26 September 2011
Author:jeroendedauw
Status:deferred (Comments)
Tags:
Comment:
work on schema
Modified paths:
  • /trunk/extensions/Contest/Contest.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.sql
@@ -5,28 +5,40 @@
66 -- Contests
77 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/contests (
88 contest_id SMALLINT unsigned NOT NULL auto_increment PRIMARY KEY,
9 - contest_name VARCHAR(255) NOT NULL, -- String indentifier for the Contest
10 - contest_enabled TINYINT NOT NULL default '0', -- If the survey can be taken by users
 9+ contest_name VARCHAR(255) NOT NULL, -- String indentifier for the contest
 10+ contest_enabled TINYINT NOT NULL default '0', -- If the contest can be taken by users
 11+ contest_submission_count SMALLINT unsigned NOT NULL --
1112 ) /*$wgDBTableOptions*/;
1213
1314 -- Contestants
1415 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/contest_contestants (
15 - contestant_id INT(10) unsigned NOT NULL auto_increment PRIMARY KEY,
16 - contestant_contest_id SMALLINT unsigned NOT NULL,
17 - contestant_user_id INT(10) unsigned NOT NULL,
 16+ contestant_id INT(10) unsigned NOT NULL auto_increment PRIMARY KEY, -- Contestant id (unique id per user per contest)
 17+ contestant_contest_id SMALLINT unsigned NOT NULL, -- Foreign key on contests.contest_id
 18+ contestant_user_id INT(10) unsigned NOT NULL, -- Foreign key on user.user_id
1819
19 - contestant_full_name VARCHAR(255) NOT NULL,
20 - contestant_user_name VARCHAR(255) NOT NULL,
21 - contestant_email TINYBLOB NOT NULL,
 20+ -- These fields will be copied from the user table on contest lock
 21+ contestant_full_name VARCHAR(255) NOT NULL, -- Full name of the contestant
 22+ contestant_user_name VARCHAR(255) NOT NULL, -- User name of the contestant
 23+ contestant_email TINYBLOB NOT NULL, -- Email of the contestant
2224
23 - contestant_country VARCHAR(255) NOT NULL,
24 - contestant_submission INT(10) unsigned NOT NULL, -- TODO
 25+ -- Extra contestant info
 26+ contestant_country VARCHAR(255) NOT NULL, -- Country of the contestant
 27+ contestant_submission INT(10) unsigned NOT NULL -- TODO: file shizzle
2528 ) /*$wgDBTableOptions*/;
2629
2730 -- Judge votes
2831 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/contest_votes (
2932 vote_id INT(10) unsigned NOT NULL auto_increment PRIMARY KEY,
30 - vote_contest_id SMALLINT unsigned NOT NULL,
31 - vote_contestant_id INT(10) unsigned NOT NULL,
32 - vote_user_id INT(10) unsigned NOT NULL,
 33+ vote_contestant_id INT(10) unsigned NOT NULL, -- Foreign key on contest_contestants.contestant_id
 34+ vote_user_id INT(10) unsigned NOT NULL, -- Judge user id
 35+ vote_value SMALLINT NOT NULL -- The value of the vote
 36+) /*$wgDBTableOptions*/;
 37+
 38+-- Judge comments
 39+CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/contest_comments (
 40+ comment_id INT(10) unsigned NOT NULL auto_increment PRIMARY KEY,
 41+ comment_contestant_id INT(10) unsigned NOT NULL, -- Foreign key on contest_contestants.contestant_id
 42+ comment_user_id INT(10) unsigned NOT NULL, -- Judge user id
 43+ comment_text TEXT NOT NULL, -- The comment text
 44+ comment_time CHAR(14) binary NOT NULL default '' -- The time at which the comment was made
3345 ) /*$wgDBTableOptions*/;
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r98183Follow up to r98148;jeroendedauw22:09, 26 September 2011

Comments

#Comment by 😂 (talk | contribs)   21:58, 26 September 2011

Couple of things:

  • Auto-incrementing id columns like comment_id are typically just unsigned ints, rather than specifying a length
  • Is there a reason for making your smallint unsigned?
  • For timestamp fields, naming convention is varbinary(14)
  • Could use some indexes (on things like timestamps and user id's)
  • You can use the shorthand /*_*/ rather than /*$wgDBprefix*/, but it'll work either way.
#Comment by Jeroen De Dauw (talk | contribs)   22:12, 26 September 2011

Cool :)

> Is there a reason for making your smallint unsigned?

Because it's unsigned...

> Could use some indexes (on things like timestamps and user id's)

Yeah, definitely. I'll add these later on, once it's clear how stuff will be accessed. I can do it now, but then I might overlook something. Also, schema is not final; it's likely to change.

Status & tagging log