DEV Community

Thomas Cansino
Thomas Cansino

Posted on

[DAY 87-89] I created a bash script to build a student database

Hi everyone! Welcome back to another blog where I document the things I learned in web development. I do this because it helps retain the information and concepts as it is some sort of an active recall.

On days 87-89, I continued where I left off last blog, which is building a student database to learn SQL by creating a bash script that uses SQL to enter information about CS students into Postgres.
Image description

I created 4 tables in the database which are: students, majors, courses, and majors_courses.

After that, I assigned primary keys for each table:

  • student_id for students table
  • major_id for majors table
  • course_id for courses table
  • major_id and course_id (composite primary keys) for majors_courses table

I also linked each table with foreign keys:

  • major_id for students table to link with majors table
  • major_id for majors_courses table to link with majors table
  • course_id for majors_courses table to link with courses table  

Then, I proceeded to create a script in bash to automate the process of inserting values in every table.

With that, I finished building the student database where I learned much about postgres queries on joining, filtering, and sorting tables. As well as making a bash script to automate the process of creating a database.
Image description

Moving forward, I started the next solo project in the course which is a database consisting of world cup games with postgres.
Image description

The requirement is that I must create a bash script that enters values into the database consisting of world cup games into PSQL.

However, this part is not done yet and I’ll be continuing this build next week. 

Overall, I thought I wasn’t going to grasp the concepts I just learned and just rely on the good ol’ “build side projects to fill in the knowledge gaps”

Fortunately, because of the repetitions throughout the whole course, I was able to quickly pick up the principles behind it. Due to this, I haven’t been having much trouble with the solo projects so far. 

I give props to freecodecamp for providing a comprehensive course about databases and scripts.

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

Top comments (6)

Collapse
 
josephj11 profile image
Joe

I'm intermediate at bash, but don't know SQL. I couldn't read the screenshots well enough to study your code. They get fuzzy when magnified (at least on my non-hd screen).

It might be better to put it in markdown code blocks, or in files somewhere, etc. Then, people could also copy and paste it if they want to try the examples or modify them.

It looks like there's a lot of value in this blog if I could read the code.

Collapse
 
thomascansino profile image
Thomas Cansino

Hey man, I'm sorry if the screenshots have poor quality, I only used a snipping tool...I'll try to do your suggestion for my next blog.

Anyways, thank you for the kind words! I didn't expect that someone will be reading my code and potentially find value in it (it's a first for me!).

Collapse
 
axorax profile image
Axorax

Agreed. I could read the code but it's pretty hard to read it.

Collapse
 
axorax profile image
Axorax

nice!

Collapse
 
thomascansino profile image
Thomas Cansino

Thank you man!

Collapse
 
axorax profile image
Axorax

no problem!