Entree > Free Design > phpBB MOD > MOD Data Base structure

| Entree | Agora | Republic |

| Election | phpBB Alternative Election MOD |

MOD Data Base structure

Tables

vote_desc

Original:

# Generation Time: Sep 17, 2004 at 10:40 PM
# Table structure for table `phpbb_vote_desc`
#

CREATE TABLE `phpbb_vote_desc` (
	`vote_id` mediumint(8) unsigned NOT NULL auto_increment,
	`topic_id` mediumint(8) unsigned NOT NULL default '0',
	`vote_text` text NOT NULL,
	`vote_start` int(11) NOT NULL default '0',
	`vote_length` int(11) NOT NULL default '0',
	PRIMARY KEY  (`vote_id`),
	KEY `topic_id` (`topic_id`)
) TYPE=MyISAM AUTO_INCREMENT=3 ;

Modded:

CREATE TABLE `phpbb_c_vote_desc` (
	`vote_id` mediumint(8) unsigned NOT NULL auto_increment,
	`topic_id` mediumint(8) unsigned NOT NULL default '0',
	`vote_text` text NOT NULL,
	`vote_start` int(11) NOT NULL default '0',
	`vote_length` int(11) NOT NULL default '0',
	`vote_type` varchar(32) NOT NULL default '',
	`vote_count` int(11) NOT NULL default '0',
	`vote_time` INT( 11 ) UNSIGNED,
	PRIMARY KEY  (`vote_id`),
	KEY `topic_id` (`topic_id`)
) TYPE=MyISAM AUTO_INCREMENT=21 ;
comment
vote_id Primary Key
topic_id Key. Which topic does the poll appear in?
vote_text The text of the question asked.
vote_start
vote_length '0' for never ending poll, or unix time.
vote_type New field necessary for this mod: Condorcet, Approval, Plurality...
vote_count In the number of ballot cast is counted here for Condorcet and Approval. For Plurality, the number of votes was calculated by adding the number of votes for each candidate, as stored in table vote_results. Obviously, Condorcet and Approval don't work this way, so the ballots must be counted here.
vote_time The time the last ballot was cast

vote_results

Original:

# Generation Time: Sep 17, 2004 at 11:12 PM
# Table structure for table `phpbb_vote_results`
#

CREATE TABLE `phpbb_vote_results` (
	`vote_id` mediumint(8) unsigned NOT NULL default '0',
	`vote_option_id` tinyint(4) unsigned NOT NULL default '0',
	`vote_option_text` varchar(255) NOT NULL default '',
	`vote_result` int(11) NOT NULL default '0',
	KEY `vote_option_id` (`vote_option_id`),
	KEY `vote_id` (`vote_id`)
) TYPE=MyISAM;
	        

Modded: same

comment
vote_id key relating to the vote. There will be as many fields with vote_id as there are options in the poll.
vote_option_id key. For each vote_id, vote_option_id will be numbered 1 to n (n = number of options in the poll.
vote_option_text Typically, the name of the candidate (and party)
vote_result In Plurality and Condorcet voting, this is where the votes are counted. The number of votes cast will be calculated by adding the votes here for each candidate (each vote_option_id) in the same poll (same vote_id).

vote_voters

Original:

# Generation Time: Sep 17, 2004 at 11:29 PM
# Table structure for table `phpbb_vote_voters`
#

CREATE TABLE `phpbb_vote_voters` (
	`vote_id` mediumint(8) unsigned NOT NULL default '0',
	`vote_user_id` mediumint(8) NOT NULL default '0',
	`vote_user_ip` char(8) NOT NULL default '',
	KEY `vote_id` (`vote_id`),
	KEY `vote_user_id` (`vote_user_id`),
	KEY `vote_user_ip` (`vote_user_ip`)
) TYPE=MyISAM;
	        

Modded: same

comment
vote_id key to poll
vote_user_id key to user in table users, so we know who already took part in the poll.
vote_user_ip For security reasons, the ip is stored in a hash form.

vote_ballots

Original: none

Modded:

# Generation Time: Sep 17, 2004 at 11:35 PM
# Table structure for table `phpbb_c_vote_ballots`
#

CREATE TABLE `phpbb_c_vote_ballots` (
	`vote_id` mediumint(9) NOT NULL default '0',
	`vote_ballot` varchar(255) NOT NULL default ''
	`voter_id` mediumint(8) default NULL
) TYPE=MyISAM;
        
comment
vote_id Which poll?
vote_ballot The condorcet ballots cannot be counted in the traditional way. Both regular (truncated) or strict (full ranking) Condorcet Ballot cast are stored here as a string like: '1;2;4;3;5'. See below for more details. Also, if a voter wants us to remember what thy voted so that they can change their vote at a later time, we store here their Approval and Plurality ballots. Note that all condorcet ballots are stored here, with or without a user id. Only part of the approval and plurality ballots are here, and only for as long as the voter wants to be able to modify the vote. this means that an entry without any corresponding user_id in necessarily a condorcet ballot.
voter_id In case the voter would like to be able to change their vote, we have to remember what they voted (in case of approval and plurality) and who cast that ballot (in case of condorcet).

The string for Condorcet ballots, although they look alike (a semi-colon separated list of the integers 1 to n) are very different in nature. Quote from the source code:

	// BE CAREFUL
	// the condorcet and condorcet_fullrank ballots
	// are saved in the same database but
	// the data saved, even though it looks the same
	// is very different in nature.
	//
	// In Condorcet, the numbers saved correspond to the ranking
	// of each candidate which are saved in a string from
	// the first candidate to the last.
	// THUS, 2;4;3;1 means that the first candidate is ranked second
	// the second candidate ranked fourth and so on...
	//
	// In Condorcet_fullrank the logic is opposite:
	// the numbers saved correspond to the number of the candidate
	// ranked from first choice to last.
	// THUS, 2;4;3;1 means that the secnod candidate is ranked first
	// the fourth candidate is ranked second and so on...

forums

Mod queries:

ALTER TABLE `phpbb_c_forums` ADD `show_vote` TINYINT AFTER `auth_vote` ;

Added or relevant fields:

comment
auth_vote Can we have polls in this forum?
show_vote Shall we show a column with number of polls and date of last polls?

users

Mod Queries:

ALTER TABLE `phpbb_c_users` 
	ADD `viewforum_show_vote` TINYINT( 1 ) 
	UNSIGNED DEFAULT '1' NOT NULL ;
comment
viewforum_show_vote If one of the forum is set to show the number of votes and the date of the last vote (in viewforum.php), the user has the choice to view it or not. With the vote information added, the page gets very wide, so it's not recommanded for small monitors. It's imperative that the users be given the choice.

This page is situated at http://www.masquilier.org/libre/phpbb/db-structure.php

It has been last updated on: 17 sep 2004

| Entree | Agora | Republic |