» tagged pages
» logout

sorted by: recent | see : popular
Content Tagged with Referendum + Documentation

About Referendum

Referendum is an issue voting system.

Essentially Referendum is a simple CRUD application, users insert votes, issues and ballots, and then read them out in tables.

Ajax Voting

The Ajax voting system works like this:
  1. User clicks on a vote
    1. Ajax fires off a request
    2. Vote class is set to pending
  2. Server receives request
    1. Server deletes all votes for the issue from the user’s IP
    2. A new vote is inserted
    3. The current tally of votes for the issue is selected from the database and returned.
  3. Client receives response – including the tally and the id of the issue.
    1. Vote tally is updated
    2. User’s vote is set to selected

Database Schema



-- Database: `referendum`
-- 

-- --------------------------------------------------------

-- 
-- Table structure for table `ballots`
-- 

CREATE TABLE `ballots` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) collate utf8_unicode_ci NOT NULL default '',
  `description` text collate utf8_unicode_ci NOT NULL,
  `created` datetime NOT NULL default '0000-00-00 00:00:00',
  `updated` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `password` varchar(32) collate utf8_unicode_ci NOT NULL default '',
  `css` text collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`),
  KEY `created` (`created`,`updated`),
  FULLTEXT KEY `description` (`description`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;

-- --------------------------------------------------------

-- 
-- Table structure for table `issues`
-- 

CREATE TABLE `issues` (
  `id` int(11) NOT NULL auto_increment,
  `ballot_id` int(11) NOT NULL default '0',
  `title` varchar(255) collate utf8_unicode_ci NOT NULL default '',
  `description` text collate utf8_unicode_ci NOT NULL,
  `created` datetime NOT NULL default '0000-00-00 00:00:00',
  `name` varchar(255) collate utf8_unicode_ci NOT NULL default '',
  `ip` int(4) NOT NULL default '0',
  `link` text collate utf8_unicode_ci NOT NULL,
  `approved` tinyint(1) NOT NULL default '0',
  `homepage` text collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `ballot_id` (`ballot_id`),
  KEY `approved` (`approved`),
  FULLTEXT KEY `description` (`description`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;

-- --------------------------------------------------------

-- 
-- Table structure for table `votes`
-- 

CREATE TABLE `votes` (
  `id` int(11) NOT NULL auto_increment,
  `issue_id` int(11) NOT NULL default '0',
  `ip` int(4) NOT NULL default '0',
  `vote` tinyint(1) NOT NULL default '0',
  `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
  PRIMARY KEY  (`id`),
  KEY `ballot_id` (`issue_id`,`ip`,`vote`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=70 ;

Images