r89497 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89496‎ | r89497 | r89498 >
Date:13:45, 5 June 2011
Author:zhenya
Status:deferred (Comments)
Tags:
Comment:
sql request
Modified paths:
  • /trunk/extensions/SocialProfile/UserStatus/UserStatus.sql (added) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserStatus/UserStatus.sql
@@ -0,0 +1,13 @@
 2+
 3+--
 4+-- Table structure `user_status`
 5+--
 6+
 7+CREATE TABLE IF NOT EXISTS `user_status` (
 8+ `id` int(11) NOT NULL AUTO_INCREMENT,
 9+ `user_id` int(11) NOT NULL,
 10+ `user_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 11+ `user_name` varchar(255) NOT NULL,
 12+ `user_status` text NOT NULL,
 13+ PRIMARY KEY (`id`)
 14+);
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStatus/UserStatus.sql
___________________________________________________________________
Added: svn:eol-style
115 + native

Comments

#Comment by Jack Phoenix (talk | contribs)   17:32, 5 June 2011
+CREATE TABLE IF NOT EXISTS `user_status` (

We don't normally include the IF NOT EXISTS clause in our table definitions, but I personally don't mind it. However, you should drop the `backticks` and prefix the table name with /*_*/ for database prefix/SQLite compatibility.

+  `id` int(11) NOT NULL AUTO_INCREMENT,
...
+  PRIMARY KEY (`id`)

The PRIMARY KEY definition should be in the initial column definition for SQLite compatibility, like this: `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT

Also, we normally prefix column fields with either the table name (if the table name is very short, such as page) or an abbreviation of the table name, for tables which have longer names. Admittedly, this is not true for all SocialProfile fields, because of historical reasons. Still, we shouldn't repeat mistakes made by others in the past. I'd suggest us as the prefix for these columns. For example:

  • idus_id
  • user_idus_user_id or maybe us_user (see for example revision.rev_user)
  • user_dateus_user_date (is this the field that holds the timestamp for the status message? If so, it should probably be called us_timestamp or something like that for consistency; see revision.rev_timestamp)
  • user_nameus_user_text (in core MediaWiki most fields that contain the user name are called something_text, for example revision.rev_user_text)
  • user_statusus_status or maybe even us_status_text (also, is text the correct type here? IIRC SocialProfile uses text for a few columns, but core MediaWiki doesn't...maybe it's not such a big deal.)

Status & tagging log