Creation of new VotingBooth rails application to expose the
[selectricity-live] / db / create.sql
1 # CREATE users TABLE
2 #####################################
3
4 #drop table if exists users;
5 #create table users (
6 # id int NOT NULL auto_increment,
7 # login varchar(80) default NULL,
8 # password varchar(40) default NULL,
9 # primary key (id)
10 #);
11
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" );
15
16 # CREATE elections TABLE
17 #####################################
18
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, 
25  primary key (id)
26 );
27
28 # CREATE candidates TABLE
29 #####################################
30
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, 
37  primary key (id)
38 );
39
40 # CREATE voters TABLE
41 #####################################
42
43 drop table if exists voters;
44 create table voters (
45  id int NOT NULL auto_increment,
46  username varchar(100) NOT NULL, 
47  password varchar(100) NOT NULL, 
48  primary key (id)
49 );
50
51 # CREATE tokens TABLE
52 #####################################
53
54 drop table if exists tokens;
55 create table tokens(
56  id int NOT NULL auto_increment,
57  token varchar(100) NOT NULL, 
58  primary key (id)
59 );
60
61 # CREATE votes TABLE
62 #####################################
63
64 drop table if exists votes;
65 create table 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),
71  primary key (id)
72 );
73
74 # CREATE rankings TABLE
75 #####################################
76
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,
83  primary key (id)
84 );
85

Benjamin Mako Hill || Want to submit a patch?