https://github.com/valentinocarmonas/students
An project made in psql for freecodecamp.org
https://github.com/valentinocarmonas/students
Last synced: 4 months ago
JSON representation
An project made in psql for freecodecamp.org
- Host: GitHub
- URL: https://github.com/valentinocarmonas/students
- Owner: ValentinoCarmonaS
- License: mit
- Created: 2025-03-05T00:07:57.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-05T00:32:43.000Z (7 months ago)
- Last Synced: 2025-05-30T08:50:39.994Z (5 months ago)
- Language: Shell
- Size: 69.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# STUDENT DATABASE PROJECT
This project involves creating and querying a PostgreSQL database to manage student information, academic majors, and courses. Part 1 focuses on database design and data insertion, while Part 2 adds advanced querying and reporting capabilities.
---
## PART 1: DATABASE CREATION & DATA INSERTION
1. **Database Setup**:
- Created a students database with four normalized tables:
- students: Student IDs, names, GPA, and major links.
- majors: Unique academic majors.
- courses: Available courses.
- majors_courses: Maps many-to-many relationships between majors and courses.
- Implemented constraints: `PRIMARY KEY`, `FOREIGN KEY`, `NOT NULL`, and composite keys.2. **Automated Data Insertion**:
- Developed a Bash script (`insert_data.sh`) to parse and insert data from `students.csv` and `courses.csv`.
- Handled CSV headers, avoided duplicates, and resolved dependencies (e.g., inserting majors/courses before linking them).
- Used `TRUNCATE` to reset tables during testing while managing foreign key constraints.3. **Data Integrity**:
- Ensured dynamic linking of majors and courses via foreign keys.
- Handled `NULL` values for students without declared majors.---
## PART 2: ADVANCED QUERYING & REPORTING
1. **Script for Student Insights**:
- Created `student_info.sh` to generate reports on student performance and course details.
- Key features:
- Filter students by GPA ranges, name patterns, or major enrollment status.
- List courses alphabetically, filter by naming patterns, or enrollment counts.
- Calculate aggregate statistics (e.g., average GPA, student counts per major).2. **Advanced SQL Techniques**:
- **Joins**: Used `FULL JOIN`, `LEFT JOIN`, and `INNER JOIN` to link tables for complex queries.
- **Pattern Matching**: Leveraged `LIKE`, `ILIKE`, and wildcards (`%`, `_`) for text searches.
- **Aggregate Functions**: `COUNT`, `AVG`, `MIN`, `MAX`, and `ROUND` for statistical analysis.
- **Grouping & Filtering**: Combined `GROUP BY` with `HAVING` to refine results.3. **Key Queries**:
- Students with GPAs ≥ 4.0 or specific name patterns.
- Courses starting/ending with letters or containing case-insensitive substrings.
- Majors with no enrolled students or those linked to specific student criteria.
- Ordered results using `ORDER BY` and limited outputs with `LIMIT`.---
## TECHNICAL CHALLENGES
- **Part 1**:
- Avoiding data duplication during CSV insertion.
- Managing foreign key dependencies across tables.
- **Part 2**:
- Optimizing query performance for large datasets.
- Combining multiple conditions (e.g., `AND`/`OR` with `LIKE`, `IS NULL`).## SKILLS DEMONSTRATED
- **Database Design**: Normalized schema, constraints, and relationships.
- **Bash Scripting**: Automated data insertion and report generation.
- **Advanced SQL**: Joins, pattern matching, aggregate functions, and query optimization.
- **Data Analysis**: Extracting insights via structured queries.---
## HOW TO USE
1. **Rebuild Database**:
```bash
psql -U postgres < students.sql
```2. **Insert Data (Part 1)**:
```bash
chmod +x insert_data.sh
./insert_data.sh
```3. **Generate Reports (Part 2)**:
```bash
chmod +x student_info.sh
./student_info.sh
```## TOOLS & TECHNOLOGIES
- **PostgreSQL**: Database management and querying.
- **Bash**: Scripting for automation.
- **CSV Files**: Raw data storage.A project completed as part of the freeCodeCamp.org Relational Database Certification.