Educational Institution Database

Gon,databaseSQLPostgreSQL

Source: Unsplash

Objective

Design a database for an educational institution to demonstrate SQL query exectutions. The database will be hosted on a Postgres server and commands given via an interactive shell. PostgreSQL (opens in a new tab) is an open source relational database and used by top companies such a Apple (opens in a new tab), Instagram (opens in a new tab), and Spotify. (opens in a new tab) SQL (Structured Query Language) is a flexible and powerful language for analysis and to retreive meaningful insight from data.

Setup the Educational Institution Database demo

This GitHub repository (opens in a new tab) contains SQL files for setting up an educational institution database, including tables for cohorts and students. Follow the steps below to get started.

Prerequisites

PostgreSQL is required to setup and run the query files. Download and install Postgres before proceeding:

Database Setup

Open Interactive Shell

Open a PostgreSQL interactive shell from the project directory. The shell allows for commands and interaction with the database:

psql

Create Database

From the interactive shell run the following command to create a new database:

CREATE DATABASE edudb;

Connect to Database

Connect to the newly created database from the shell:

\c edudb;

Run Migrations

Execute migration files to create tables in the database:

\i migrations/students_cohorts.sql
\i migrations/assignment_submissions.sql
\i migrations/teachers_assistance_requests.sql

Seed the Database

Populate the tables with sample data using seed files:

\i seeds/students.sql
\i seeds/teachers_seeds.sql
\i seeds/cohorts.sql
\i seeds/assignments_seeds.sql
\i seeds/assignment_submissions_seeds.sql
\i seeds/assistance_requests_seeds.sql

Run SQL Queries

Explore and execute SQL query files to perform analysis on the educational institution database.

SQL query file directories:

0_selects
1_queries
2_queries_joins
3_queries_group-by
4_queries

Example SQL Queries

The query files demonstrate a range of statistical analysis using the sample data. Here are some of the queries available to run in the in the fileset: