2 #####################################
4 #drop table if exists users;
6 # id int NOT NULL auto_increment,
7 # login varchar(80) default NULL,
8 # password varchar(40) default NULL,
12 ## Create a default system user to own stage directions
13 ## and similar. Users cannot log in.
14 #insert into users ( id, login ) values ( 1, "System Defaults" );
16 # CREATE elections TABLE
17 #####################################
19 drop table if exists elections;
20 create table elections (
21 id int NOT NULL auto_increment,
22 name varchar(100) NOT NULL,
23 description TEXT NOT NULL,
24 anonymous tinyint NOT NULL DEFAULT 0,
28 # CREATE candidates TABLE
29 #####################################
31 drop table if exists candidates;
32 create table candidates (
33 id int NOT NULL auto_increment,
34 election_id int NOT NULL,
35 name varchar(100) NOT NULL,
36 picture blob NOT NULL,
41 #####################################
43 drop table if exists voters;
45 id int NOT NULL auto_increment,
46 username varchar(100) NOT NULL,
47 password varchar(100) NOT NULL,
52 #####################################
54 drop table if exists tokens;
56 id int NOT NULL auto_increment,
57 token varchar(100) NOT NULL,
62 #####################################
64 drop table if exists votes;
66 id int NOT NULL auto_increment,
67 voter_id int DEFAULT NULL,
68 token_id int DEFAULT NULL,
69 constraint fk_vote_voter foreign key (voter_id) references voters(id),
70 constraint fk_vote_token foreign key (token_id) references token(id),
74 # CREATE rankings TABLE
75 #####################################
77 drop table if exists rankings;
78 create table rankings (
79 id int NOT NULL auto_increment,
80 vote_id int DEFAULT NULL,
81 candidate_id int DEFAULT NULL,
82 rank int DEFAULT NULL,