This is my first back end project using a SQL database. The SQL version of choice is MySQL and the Express package was used to populate and manipulate my database using RESTful APIs through CRUD methods. API endpoints are tested using Insomnia application since this app does not include a front end.
U Develop It is a make believe web developer community in search of new club president. To select a president, the community decided to make a MySQL database titled "election" to facilate the election process. The layout of the database is labeled below:
This application can only run locally. Please check below on how to install.
- Candidates
- Parties (Candidates may or may not be part of a web development party, ex: "Heroes of HTML")
- Voters
- Votes (Indicates which candidate the voter voted for with the use of primary keys)
- GET (ALL candidates, ONE candidate, ALL parties, ONE party, ALL voters, ONE voter, ALL votes, ALL votes that show count per candidate and their affilated party if any)
- POST (ONE candidate, ONE voter, ONE vote)
- PUT (CHANGE a candidate's affilated party, CHANGE voter's email address)
- DELETE (DELETE a candidate, DELETE a party, DELETE a voter)
- Candidates refer to affilated party through the party's primary key
- If a party is deleted, the candidate's party info will be set to NULL
- Votes refer to voter through the voter's primary key
- Voters cannot vote more than once
- If a voter leaves the club (DELETE route), the vote is deleted
- Votes refer to the candidate chosen by the voter through the candidate's primary key
- If a candidate withdraws from the race (DELETE route), the vote is deleted
- Git clone or download the application and load on VSCode
- Run 'npm install' in the Command Line, make sure MySQL and Express are installed.
- If this is your first time installing MySQL, please navigate to their documentation for proper installation into your computer and credential creation
- Change your package.json scripts to your chosing, preferred to include "start" : "node server.js" as one of your scripts
- Navigate to db/connection.js and include your MySQL user and password in the fields commented. Save your edits.
- Go to the MySQL shell in your terminal and type the following commands to download the original database from '/db'
- SOURCE db/db.sql
- SOURCE db/schema.sql
- SOURCE db/seeds.sql
- Install Insomnia and manually create the routes you wish to test.
- Quit the MySQL shell and run 'npm start' in the terminal. If port 3010 is in use, kill it or use another port.