Difference between revisions of "InstaGov/schema/rating"
Jump to navigation
Jump to search
m |
(revisions to timestamp fields; clarified field comments) |
||
Line 6: | Line 6: | ||
** Changes to ratings are logged in the {{l/same|rating log}}. | ** Changes to ratings are logged in the {{l/same|rating log}}. | ||
==History== | ==History== | ||
− | * '''2013-01-09''' Removed the "ID_Proxy" field; see {{l/same|rating_log}} for explanation; added unique key: one rating per answer per user | + | * '''2013-01-09''' Removed the "ID_Proxy" field; see {{l/same|rating_log}} for explanation; added unique key: one rating per answer per user; added WhenEdited |
==SQL== | ==SQL== | ||
<mysql>CREATE TABLE `rating` ( | <mysql>CREATE TABLE `rating` ( | ||
− | `ID` INT | + | `ID` INT NOT NULL AUTO_INCREMENT, |
− | `ID_User` INT COMMENT "user | + | `ID_User` INT NOT NULL COMMENT "ID of user who gave this rating", |
− | `ID_Answer` INT NOT NULL COMMENT "answer | + | `ID_Answer` INT NOT NULL COMMENT "ID of answer for which this is a rating", |
− | `ID_Log` INT NOT NULL COMMENT "ID of log | + | `ID_Log` INT NOT NULL COMMENT "ID of log entry for the most recent update of this rating", |
− | `Value` INT NOT NULL COMMENT "rating value", | + | `Value` INT NOT NULL COMMENT "rating value", |
− | ` | + | `WhenCreated` DATETIME NOT NULL COMMENT "when this user first rated this answer", |
− | `Remark` VARCHAR(255) COMMENT "comments on this rating (can include link)", | + | `WhenEdited` DATETIME DEFAULT NULL COMMENT "when this rating (of this answer) was last edited (by this user)", |
+ | `Remark` VARCHAR(255) COMMENT "comments on this rating (can include link)", | ||
PRIMARY KEY(`ID`), | PRIMARY KEY(`ID`), | ||
UNIQUE KEY(`ID_User`,`ID_Answer`) | UNIQUE KEY(`ID_User`,`ID_Answer`) | ||
) | ) | ||
ENGINE = MYISAM;</mysql> | ENGINE = MYISAM;</mysql> |
Revision as of 23:13, 9 January 2013
About
- Purpose: Records the current value of one user's rating of a given answer (which in turn is tied to a specific question. These are the values which are aggregated to calculate the voting results for each question.
- Rules:
- Any answer may have zero or more ratings.
- Each user sets the value of their rating for each answer, and can change that rating at any time.
- Changes to ratings are logged in the rating log.
History
- 2013-01-09 Removed the "ID_Proxy" field; see rating_log for explanation; added unique key: one rating per answer per user; added WhenEdited
SQL
<mysql>CREATE TABLE `rating` (
`ID` INT NOT NULL AUTO_INCREMENT, `ID_User` INT NOT NULL COMMENT "ID of user who gave this rating", `ID_Answer` INT NOT NULL COMMENT "ID of answer for which this is a rating", `ID_Log` INT NOT NULL COMMENT "ID of log entry for the most recent update of this rating", `Value` INT NOT NULL COMMENT "rating value", `WhenCreated` DATETIME NOT NULL COMMENT "when this user first rated this answer", `WhenEdited` DATETIME DEFAULT NULL COMMENT "when this rating (of this answer) was last edited (by this user)", `Remark` VARCHAR(255) COMMENT "comments on this rating (can include link)", PRIMARY KEY(`ID`), UNIQUE KEY(`ID_User`,`ID_Answer`) ) ENGINE = MYISAM;</mysql>