<aside> 💡 Use this template to document your approach to interviewing engineers.

</aside>

Setup

To install PotgreSQL on a Ubuntu server, follow the official instructions from postgresql.org:

# Create the file repository configuration:
sudo sh -c 'echo "deb <http://apt.postgresql.org/pub/repos/apt> $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# Import the repository signing key:
wget --quiet -O - <https://www.postgresql.org/media/keys/ACCC4CF8.asc> | sudo apt-key add -

# Update the package lists:
sudo apt-get update

# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql

By default, PostgreSQL will associate its roles (i.e. users) with Linux system accounts of the same name. If a role exists in PostgreSQL for a Linux user account with the same name, that user is able to log in as that role. The default account installed with PostgreSQL is postgres, associated with the default postgres role. You can (1) either switch to the postgres user and access the database or (2) access the database directly as any user with the postgres role:

  1. sudo -i -u postgres and then psql
  2. psql -u postgres

Either way, you’ll be prompted for the password. As the postgres role you can then create a new role that has the permission to create new databases:

CREATE USER username WITH PASSWORD 'password' CREATEDB;

Use this new role from now on to access the database and make modifications. You can use the createdb.py script, found in the server folder of the RF survey repository, to create the database structure necessary to accommodate the RF survey system. The script requires the Python package psycopg2, which can be installed with pip3 install psycopg2. The createdb.py script creates the 10 tables seen in the database block diagram: