-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSETUP_DATABASE.sql
More file actions
20 lines (15 loc) · 810 Bytes
/
SETUP_DATABASE.sql
File metadata and controls
20 lines (15 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- Just create the database
CREATE DATABASE IF NOT EXISTS voting;
-- Set voting to the current database we are useing
USE voting;
CREATE TABLE IF NOT EXISTS current_poll ( -- Table that holds the current thing we are voting on
id enum('1') NOT NULL, -- This forces the column to only be 1
name VARCHAR(150) NOT NULL, -- The name of the person we are voting on
PRIMARY KEY (id) -- Force id to be unique so since it can only be 1 the table can only have 1 row
);
CREATE TABLE IF NOT EXISTS votes ( -- Table to hold the votes people cast
name VARCHAR(150) NOT NULL, -- Name of the thing we are voting on
vote enum('YES', 'NO', 'ABSTAIN') NOT NULL -- The only possible votes
);
GRANT SELECT,INSERT,DELETE ON voting.* TO 'secretVote'@'%' IDENTIFIED BY 'test';
flush privileges;