DEV Community

Ian Bonaparte
Ian Bonaparte

Posted on

Front-End to Full-Stack Journey: SQL & SQLite

In sticking with holding myself accountable on my journey, I am happy to be writing part 2. I've been quiet this past week or so because I am focusing on actually learning what I want to do, instead of just diving head first into the project and getting lost in tutorials. I am hopeful that my patience will pay off.

Code Academy

I took advantage of Code Academy's free courses and completed "Introduction to Backend Programming" and "Learn Node.js Fundamentals". This felt necessary for me as I've done React projects and other node projects before, but I never actually understood what I was doing with node. These courses definitely helped give me the basic understanding that I need. My brain has always worked in a way where I need to understand the why of something for it to click. I can't just be told what to do, my brain needs to understand the implications for it to fully set in for me.

I actually enjoyed these so much that I took advantage of the current holiday 50% off deal and signed up for a year. I love the way they lay the material out into chunked-up sections and give you exercises to test your understanding. It is a seriously great and intuitive learning tool. The phone app is also excellent. You can replace some mindless scrolling with some flash-card content on whatever topic you are attempting to learn. I'm not even sponsored or paid, but I highly recommend everyone check it out.

Express and Middleware

In my google queries of "How to connect React component to SQL database", I learned that I need another technology on top of Node & React. I also finally learned what the "E" stands for in certain stacks (MERN, MEAN, etc.) and why so many different frameworks are needed.

So, with my newly acquired Code Academy account, I have been taking Express courses to keep up with my new-self. I have completed about 50% of the "Learn Express" course and already feel confident and ready to tackle the next part of my College Football Dynasty project.

SQLite Queries

On a more boring front, I have imported almost all of the data from our Google Sheets (see previous failed attempt at using Google Sheets as a database). I am proud of how clean the tables and data looks (so far).

I have also been learning SQL on the side, and trying to fully understand the best way to join my tables and extract the data I need for my project. I am confident I can learn this on-the-fly as it makes sense, I just need to understand the syntax better.

My crowning SQL achievement at the moment, is that I was able to extract one team's total Wins, Losses, In-Conference Wins, and In-Conference losses from 1 specific season. I have one giant table for every match played in the league with columns for teams, scores, game-types (playoffs, reg season etc). This is what my query looked like and what it returned:

SELECT COUNT(CASE WHEN (home_id='53' AND home_score > away_score) OR (away_id='53' AND away_score > home_score)THEN 1 END) AS Wins,
COUNT(CASE WHEN (home_id='53' AND home_score < away_score) OR (away_id='53' AND away_score < home_score)THEN 1 END) AS Losses,
COUNT(CASE WHEN game_type LIKE '%Conference Play%' AND ((home_id='53' AND home_score > away_score) OR (away_id='53' AND away_score > home_score))THEN 1 END) AS Conf_Wins,
COUNT(CASE WHEN game_type LIKE '%Conference Play%' AND ((home_id='53' AND home_score < away_score) OR (away_id='53' AND away_score < home_score))THEN 1 END) AS Conf_Losses
FROM matches
Enter fullscreen mode Exit fullscreen mode

Wins: 4, Losses: 8, Conference Wins: 3, Conference Losses: 6

Probably pretty simple SQL but it did wonders for my confidence that I am going to be able to extract the data that I actually need for my site.

Up Next

I am going to continue through my Express course, and then I will officially start the project. I just want to display a dynamic list of all the teams and members part of the league to get started. I will build functionalities and team pages from there! I feel like once my environment is set-up and I have the confidence to pull the data I need, the site will be built quickly as my expertise is with HTML/CSS.

Top comments (0)