This repository is made to help students of the MAS DSE 201 course offered in Winter 2015 at UCSD. It contains documentation on software required for the course.
- The recommended way to install PostgreSQL in Mac OS X is using Postgres.app. Follow the instructions on the website to install the software. This will install PostgreSQL version 9.4.
- Once you installed the application, launch it and you should see a small elephant on your toolbar (see screenshot).
) - Click on "Open psql" and you are presented with an interactive shell you can use for SQL commands.
The above installation only provides a command line interface for PostgreSQL. For those who prefer a Graphical User Interface, follow these steps to install PgAdmin. Note that you still need to complete the steps above to install PostgreSQL itself.
- Download PgAdmin here.
- Open PgAdmin in click on the Connect button in the top right corner (looks like a plug).
- Configure PgAdmin as follows (replacing
julestestardby your MacOS username) then click OK (don't put a password) :
- Back to the main page, you should see a
<your_username>server with a<your_username>database. If the server is shown with a cross onto it, just double click it (this should start the connection).
- You're good to go! I suggest following online guides on PgAdmin for further details about the GUI.
- The first step is to install postgres with the following PostgreSQL as follows : run
sudo apt-get install postgresqlon the terminal. Verify that the installed version of PostgreSQL. The version number shouldn't matter as long as it's fairly recent (version 9.0+). - Run
sudo -u postgres createuser -s <username>on the terminal. By default, the PostgreSQL installation will install a user calledpostgreswhich will have the administrator role (highest level of privilege). In our case, it is OK to have our own user be a super user as well. This command creates a new user (which bears our own name) and gives it administrator powers. - Run
createdb <username>on the terminal. This will create a database whose name is the same as our own name. - Run
psqlon the terminal and you will have a client session to your database. Note thatpsqlis a shorthand forpsql -U <username> -d <username>, which means "create a client connection to the database <username> as user <username>".
The above installation only provides a command line interface for PostgreSQL in Linux. For those who prefer a Graphical User Interface, follow these steps to install PgAdmin. Note that you still need to complete the steps above to install PostgreSQL itself.
- The first step is to install PgAdmin. For this, just run
sudo apt-get install pgadmin3on the terminal. - Follow steps 2-5 found on the MacOS PgAdmin install.
- Download Postgresql 9.4
- Click Next
) - Click Next

- Provide password (e.g. postgres)

- Click Next

- Click Next

- Click Next

- Click Finish

- Launch psql and put in password for user postgres (defaults for other fields is ok for now)

- Launch pgAdmin

- Double click on PostgresSQL 9.4 and put in the password for user postgres

At this point we assume you have logged into PostgreSQL through psql (see section 1 for PostgreSQL installation for your system).
Please download and unzip the sql.zip at a convenient location on your system. To load data from sql within psql, do the following (in Linux or MacOS):
psql> \i <path_to_location>/sql/create_tables_enrollment.sql
psql> \i <path_to_location>/sql/create_tables_movie.sql
Do the following (in Windows):
psql> \i <path_to_location>\sql\create_tables_enrollment.sql
psql> \i <path_to_location>\sql\create_tables_movie.sql
To run a few example queries, do the following (in Linux or MacOS):
psql> \i <path_to_location>/sql/run_queries_enrollment.sql
psql> \i <path_to_location>/sql/run_queries_movie.sql
Do the following (in Windows):
psql> \i <path_to_location>\sql\run_queries_enrollment.sql
psql> \i <path_to_location>\sql\run_queries_movie.sql