Which database should I use?

There are many relational database management systems, or RDBMS such as SQLite, MS SQL, PostgreSQL and MySQL. Some are lightweight, easy to install and use, while others are robust, scalable, but are complex to install. The goal of this book is to teach you SQL, which would allow you to use any of the RDBMS's mentioned above, and even others not mentioned.

Database engines

We have chosen PostgreSQL Version 9.4.5 for this book for its wide usage and stability. Any version of PostgreSQL > 9.4 is fine to use. PostgreSQL is a "client-server" database, which is an architecture design used by most relational databases.

What is "Client-Server" architecture?

An analogy for this would be a sushi restaurant where a chef in the center is preparing sushi and people walk up from their tables to order and then to pick up their food. You can think of the chef as the server, the food as the data and the customer as the client. With a database, we connect to the server, such as a PostgreSQL server, using a client, like a PostgreSQL Client. The client transmits commands to the server and the server sends the result or data back.

Client server architecture

Installing PostgreSQL

To Get Started, Install PostgreSQL for your Operating System.

Mac OSX install

For MacOS X we will use Homebrew to install. If you don't have it installed follow the instructions on the homebrew's homepage to install it.

First, we ensure that Homebrew is up to date

$ brew update
$ brew doctor
$ brew upgrade

Next, follow the instructions listed in one of our blog posts. When reading this blog post, you only need to follow instructions for installing PostgreSQL; you should skip the section on Rails. link.

Linux Install

On a linux machine, your easiest route for installation is to use the package manager included with your distribution. Instructions on how to install PostgreSQL are included in this link.

Congratulations! Your PostgreSQL server is running

Optional PostgreSQL Password

Some users may want to add a bit of security so that not just anyone can access their PostgreSQL databases. PostgreSQL gives us the option to set a password for the entire installation of PostgreSQL, and even for particular databases. You can find more information about setting a password in the docs for psql: look for the meta command \password and the option --password. For more information about setting passwords for particular users, databases, and hosts, check out the page on the password file.