This project involves creating a relational database for managing various operations of an educational platform using PostgreSQL
View the Project on GitHub themispap/SQL_project_phi_database
This project is a relational database designed for the educational platform of ‘Φ’ Maths & Statistics Lab. The database captures various aspects of the business operations, including data analysis projects, university courses, and secondary school lessons. This provides an overview of the database schema, data flow, and instructions for setting up and using the database.
The ‘Φ’ Maths & Statistics Lab offers three main services:
The database structure is designed to efficiently manage information related to projects, students, customers, courses, lesson plans, payments, and income.
The database consists of the following tables (see schema):
projects
learning_plans
courses
payments
income
records
students
customers
Column Name | Data Type | Description |
---|---|---|
project_id | SERIAL | The unique ID of the project (Primary Key) |
subject | VARCHAR | The subject of the project |
customer_id | INT | The customer ID from the customers table (Foreign Key) |
price | DECIMAL | The price charged for the project |
deadline | DATE | The deadline of the project |
submission_date | DATE | The date of taking over the project |
Column Name | Data Type | Description |
---|---|---|
plan_pkey | SERIAL | Learning plan primary key (Primary Key) |
plan_id | INT | The ID of the learning plan (Unique) |
price | DECIMAL | The price of the learning plan |
description | VARCHAR | The description of the learning plan |
charge_type | VARCHAR | Billing type (monthly, hourly) |
duration | INT | The total weekly duration of the lessons in the learning plan |
courses | VARCHAR | The courses included in the learning plan |
acad_year | VARCHAR | The academic year of the learning plan |
Column Name | Data Type | Description |
---|---|---|
course_id | SERIAL | The unique ID of the course (Primary Key) |
course_name | VARCHAR | The name (title) of the course |
grade | VARCHAR | 1st, 2nd, etc. |
rank | VARCHAR | Middle School, High School, Undergraduate, Postgraduate |
Column Name | Data Type | Description |
---|---|---|
payment_pkey | SERIAL | Payment primary key (Primary Key) |
amount | DECIMAL | The monetary amount of the transaction |
cause | VARCHAR | The reason for the transaction |
category | VARCHAR | The category of the payment |
issue_date | DATE | The issue date of the transaction |
paydate | DATE | The date of the transaction |
status | VARCHAR | The status of the payment (‘pending’,’paid’) |
Column Name | Data Type | Description |
---|---|---|
income_pkey | SERIAL | Income primary key (Primary Key) |
amount | DECIMAL | The monetary amount of the transaction |
customer_id | INT | The customer ID from the customers table (Foreign Key) |
cause | VARCHAR | The reason for the transaction |
charge_date | DATE | The due date of the transaction |
paydate | DATE | The date of the transaction |
Column Name | Data Type | Description |
---|---|---|
record_pkey | SERIAL | Record primary key (Primary Key) |
record_date | DATE | The date of the course |
duration | INT | The duration of the course |
student_id | INT | The student ID from the students table (Foreign Key) |
course_id | INT | The course ID from the courses table (Foreign Key) |
Column Name | Data Type | Description |
---|---|---|
student_pkey | SERIAL | Student primary key (Primary Key) |
signup_date | DATE | The enrollment date of the student |
student_id | INT | The unique ID of the student |
student_name | VARCHAR | The name of the student |
surname | VARCHAR | The surname of the student |
mobile | VARCHAR | The mobile phone number of the student |
VARCHAR | The email of the student | |
grade | VARCHAR | 1st, 2nd, etc. |
rank | VARCHAR | Middle School, High School, Undergraduate, Postgraduate |
school | VARCHAR | The school the student attends |
parent_id | INT | The customer ID from the customers table (Foreign Key) |
plan_id | INT | The plan ID from the learning_plans table (Foreign Key) |
discount | DECIMAL | The discount given to the student |
cohort | VARCHAR | The class in which the student is enrolled |
del_date | DATE | The student’s deletion date |
acad_year | VARCHAR | The academic year in which the student was enrolled |
Column Name | Data Type | Description |
---|---|---|
customer_id | SERIAL | The unique ID of the customer (Primary Key) |
customer_name | VARCHAR | The name of the customer |
surname | VARCHAR | The surname of the customer |
mobile | VARCHAR | The mobile phone number of the customer |
phone | VARCHAR | The phone number of the customer |
VARCHAR | The email of the customer | |
address | VARCHAR | The home address of the customer |
zip | VARCHAR | The ZIP code of the customer |
region | VARCHAR | The region the customer lives in |
city | VARCHAR | The city the customer lives in |
lat | DECIMAL | The latitude of the customer’s address |
lon | DECIMAL | The longitude of the customer’s address |
active | BOOLEAN | Whether a customer is active or not |
projects
and customers
tables.students
and customers
tables.students
table and the customers
table with their guardian’s details.courses
table.learning_plans
table.records
table.payments
table, while income is recorded in the income
table.git clone https://github.com/your-username/SQL_project_phi_database.git
cd SQL_project_phi_database
CREATE DATABASE phi_maths_stats_lab;
psql -d phi_maths_stats_lab
\i schema.sql
You can run various SQL queries to generate reports, such as:
Balance of every customer for the selected academic year (open query)
customer name | customer surname | credit | debit | balance |
---|---|---|---|---|
… | … | … | … | … |
… | … | … | … | … |
Monthly revenue (open query) and cost (open query) for the selected academic year
month | income / cost |
---|---|
… | … |
… | … |
Example queries are provided in the queries
folder.
This project is licensed under the MIT License - see the LICENSE file for details.