DEV Community

Thomas Cansino
Thomas Cansino

Posted on

[DAY 90-92] I made a shell script to build me a world cup database

Hi everyone! Welcome back to another blog where I document the things I learn in web development. I do this because it helps retain the information and concepts through active recall.

On days 90-92, I finished building a script to automate creating a database, a translator using a shell script, and started building an interactive bash program.

The first project is where I created a bash script to make a database about world cup matches in PostgreSQL. This is part 2 out of 5 certification projects in the relational databases course in freecodecamp. I also made a script on the side to query useful statistics from the database.
Image description

In this course, I was given a spreadsheet of a list of world cup games in 2014 and 2018.

What I did first is to make a database with 2 tables: games and teams.

After that, I assigned primary keys for each table:

  • game_id for games table
  • team_id for teams table

I also linked the tables with foreign keys:

  • opponent_id & winner_id for games table to link with teams table
  • team_id for teams table to link with games table

Next, I created a shell script to insert all the data from the spreadsheet to the database.

Finally, I made a script to query all the useful statistics from the database like who won the 2018 finals, list of teams that won in 2014, etc.
Image description
Image description

The next project is a translator using a shell script that translates cat texts to dog texts to learn advanced bash commands like sed, grep, redirection, and piping operators.
Image description

In this course, I was given a lorem ipsum about cats.

What I did first is to make a one-liner script using the sed command (stream editor).

When the script is initialized, the texts will be translated to lorem ipsum about dogs.

The next project is an interactive bash program where I must build a database about renting and returning bikes to learn more Bash and PSQL.
Image description

The first thing I did is to create the tables with columns, primary keys, and foreign keys to link all of them.

The next part is to write a shell script that makes the database interactive which I’ll be continuing on the next blog.

Anyways, that’s all for now. More updates in my next blog! See you there!

Top comments (0)