This repo is meant to give you a quick guide to getting up and running with mysql in node.js.
These exercises are geared to help you understand how to move your data processing to the database, which will keep your program free to perform other operations.
Databases are very efficient. Don't be afraid to use them.
- Install mysql server: MySQL Downloads
- Take note of your MySQL server settings
- Fork this repo, then run
npm install
- Modify the config settings in
index.js
to match your server settings - Run the SQL scripts in the
creation/
folder on your database. - Open
index.js
- Follow along with the comments! The code is provided, but try to experiment!
- Answer the questions listed under 'Goals'
Answer these questions by running queries on node and processing the data by whatever means necessary (map, reduce, and filter are allowed):
- How many games were played total?
- hint: try to use the COUNT function in SQL
- Which clan does Alice belong to? How about Bob?
- Challenge: try using an inner join (or two)
- How many games did Alice play against Bob?
- Challenge: try to include each player's name
- Challenge:* How many games did each player play against each other player?
- Which clan won the most games?
*this one could be pretty difficult
After you can answer those (confidently) using SQL and javascript together, try implementing them using only SQL to get the same result.