Skip to content

Instantly share code, notes, and snippets.

@subfuzion
Last active June 20, 2018 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subfuzion/f8c66c8aac9e7f73ad773a8605540db5 to your computer and use it in GitHub Desktop.
Save subfuzion/f8c66c8aac9e7f73ad773a8605540db5 to your computer and use it in GitHub Desktop.
Vote Database Queries

Overview

For Voting App

Need MySQL queries for the following:

  1. Statement: create voter. Register a unique username of reasonable lengths (3-64 characters, such as "tonypujals" and password to be able to vote. Password field will store bcrypt-encrypted strings, specifically:
  • CHAR(60)
  • CHARACTER SET latin1
  • COLLATE latin1_bin
  1. Query: fetch encrypted password for voter username. Will be used to compare encrypted strings for login.

  2. Statement: create a poll. A poll is a unique name, such as "cats_vs_dogs" and identifies the names of the available choices to vote for (eg, "cats", "dogs"). The choices should have a simple incrementing unique ID (1, 2, 3, etc.)

  3. Statement: cast ballot. A ballot has a voter, a poll, and vote.

  4. Query: fetch voter's vote for a particular poll (ex: "cats").

  5. Query: fetch vote results for a particular poll (ex: cats: 5, dogs: 3)

Run on Aurora.

@subfuzion
Copy link
Author

subfuzion commented Jan 24, 2018

  1. Create a bridge network to use for communication between a MySQL CLI and database.
    $ docker network create --driver bridge sqlnet
  1. Start a MySQL database container.
    $ docker run -d --name mysql --network sqlnet -e MYSQL_ROOT_PASSWORD=secret mysql:latest
  1. Start a MySQL command-line client.
    $ docker run -it --rm --name mysqlcli --network sqlnet mysql:latest sh -c 'exec mysql -h mysql -uroot -p'
    Enter password: _

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment