PostgreSQL Database

Thursday, 11 Oct 2018 Kudzai Nyandoro

PostgreSQL is a powerful open-source object-relational database management systems (ORDBMS) that comes packed with many features and it is free to use. I use PostgreSQL, often called Postgres, for building web applications and experimenting with SQL. When I started building web applications, I did not know how to write a single line of SQL. I started building web applications with Ruby on Rails without any knowledge of SQL. However, when I wanted to expand my knowledge on building databases and web development I noticed that learning more about what goes on at the database level of the Ruby on Rails framework would be helpful for me.

Ruby on Rails comes loaded with SQLite3 as the default database, however, I'm going to be using PostgreSQL for my SQL tutorials. PostgreSQL can be installed on any major operating system such as Mac OS X, Linux, and windows. If you want to learn more about PostgreSQL, you can visit this link. To download and install PostgreSQL you can visit the Downloads page. Depending on your system there are several ways to install PostgreSQL. If you're on a Mac OS X make sure you have Homebrew installed first. If you do not have Homebrew installed open your terminal and run the line provided below. Otherwise, skip and go to the next step.

$ ruby -e "$(curl -fsSL"

To install PostgreSQL on a Mac OS X, if you already have Homebrew installed, open your terminal and run the line below.

$ brew install PostgreSQL

I'm not sure what operating system everyone is using so I'm not going get into the details of how to install this software on other systems because of the many different options, distinct operating systems, and varying personal preferences. One can also do a search online to find out how someone else has done it in the past. Another great alternative, if you don't want to deal with installing anything on your computer, is c9. If you have installed PostgreSQL, stay tuned for some SQL tutorials coming soon.

Web application frameworks like Ruby on Rails come loaded with many different layers. Ruby on Rails can be very user-friendly when it comes to building and deploying a web application within a short space of time. As a newbie, I ran into a lot of trouble when I had to debug my applications because I did not know where to start the debugging process. I would see all the many error messages flooding my console and this would often make me just want to get up and leave -- as if that would solve the problem.

I'm writing this series of tutorials for anyone who is in the same position as I was a few years ago. It's important to learn about the many different layers in whatever technology stack one chooses to use when building her web applications. One of the best advice I've heard came from Ryan Bates in one of his RailsCasts episodes, Getting Started with Rails, where he says "After you've gone through a couple of tutorials and you find that things still aren't clicking, I recommend the divide and conquer approach. Ruby on Rails uses many different technologies and it's a lot to learn, all at one time." He goes on the recommend learning each technology in isolation. I have and continue to follow his advice, learning HTML, CSS, Ruby, JavaScript, and SQL has really helped to improve on my coding skills. So thank you, Ryan.

Our focus for the next few tutorials is is going to be on learning about the database level of web development, learning the SQL language using PostgreSQL. Further down the road, we will be connecting these databases to frameworks like Sinatra and Ruby on Rails. For the time being, let's take the baby steps.