{"id":32778661,"url":"https://github.com/msmrexe/postgres-academic-performance-analyzer","last_synced_at":"2026-05-17T04:35:32.563Z","repository":{"id":320642719,"uuid":"1082878958","full_name":"msmrexe/postgres-academic-performance-analyzer","owner":"msmrexe","description":"An academic performance analyzer for PostgreSQL. Generates student transcripts, calculates semester/cumulative GPAs, and provides departmental performance insights.","archived":false,"fork":false,"pushed_at":"2025-10-24T23:28:39.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-25T01:11:05.054Z","etag":null,"topics":["academic-performance-analytics-system","course-project","databases","postgresql","sql","university-project"],"latest_commit_sha":null,"homepage":"","language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msmrexe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-24T23:14:09.000Z","updated_at":"2025-10-24T23:35:15.000Z","dependencies_parsed_at":"2025-10-25T01:11:06.702Z","dependency_job_id":"4513ca62-731f-4942-9566-f913f47a75ff","html_url":"https://github.com/msmrexe/postgres-academic-performance-analyzer","commit_stats":null,"previous_names":["msmrexe/postgres-academic-performance-analyzer"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/msmrexe/postgres-academic-performance-analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmrexe%2Fpostgres-academic-performance-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmrexe%2Fpostgres-academic-performance-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmrexe%2Fpostgres-academic-performance-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmrexe%2Fpostgres-academic-performance-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msmrexe","download_url":"https://codeload.github.com/msmrexe/postgres-academic-performance-analyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmrexe%2Fpostgres-academic-performance-analyzer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":282658688,"owners_count":26705665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-04T02:00:05.887Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["academic-performance-analytics-system","course-project","databases","postgresql","sql","university-project"],"created_at":"2025-11-04T15:01:19.578Z","updated_at":"2025-11-04T15:02:25.028Z","avatar_url":"https://github.com/msmrexe.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Academic Transcript Generator \u0026 Analyzer (PostgreSQL)\n\nThis project simulates a smart university academic analyzer within a PostgreSQL database. It uses advanced PL/pgSQL functions, views, and window functions to generate detailed student transcripts, calculate semester and cumulative GPAs, and provide analytical views based on academic performance.\n\nThis project was developed from a series of \"Mathematical Databases\" course homework assignments to create a single, cohesive, and self-contained application.\n\n## Features\n\n* **Accurate Grade Point Conversion:** A standardized function converts letter grades (e.g., 'A', 'B+', 'C-') to a standard numerical 4.0 scale (e.g., 4.0, 3.3, 1.7), correctly handling non-GPA-applicable grades.\n* **Transcript Generation Function:** A `udf_generate_transcript(student_id)` function returns a complete academic history for a student, grouped by term, showing all courses, credits, grades, semester GPA, and a *running* cumulative GPA.\n* **Credit-Weighted GPA Logic:** All GPA calculations are correctly weighted by course credits and properly handle `NULL` or non-standard grades.\n* **Student Summary View:** A `v_student_overall_summary` view provides a high-level look at each student's total *earned* credits and final cumulative GPA.\n* **Department Performance View:** A `v_department_performance` view calculates the true, credit-weighted average GPA for all students in each department.\n* **Dean's List Function:** A `udf_get_deans_list(semester, year, min_gpa)` function returns students who meet a specific GPA threshold for a given term.\n\n## Database Concepts Showcased\n\n* **Advanced SQL:** Extensive use of multi-table joins, aggregations (`SUM`, `AVG`, `COUNT`), and complex `CASE` statements.\n* **Window Functions:** The core of the project. Used to calculate running totals for cumulative GPA (`SUM(...) OVER (PARTITION BY ... ORDER BY ...)`).\n* **PL/pgSQL:** Writing table-returning functions (`RETURNS TABLE`) to create a clean, parameterized API for reports.\n* **Database Views:** Creating a layered system of views (`v_student_grade_points` -\u003e `v_student_academic_summary` -\u003e `v_student_overall_summary`) to abstract complexity and promote reusability.\n* **Data Transformation:** Converting data from one format to another (letter grades to numeric points) and aggregating transactional data (`takes`) into meaningful reports.\n* **Reporting \u0026 Analytics:** Generating meaningful summaries (transcripts, departmental performance) from raw data.\n\n---\n\n## How It Works\n\nThe system is built on two pillars: the database schema (the tables) and the business logic (the functions and views).\n\n### 1. Database Schema Overview\n\nThis project builds on the existing university schema. The logic primarily revolves around these key tables:\n\n* **`student`**: Stores student information (ID, name, department).\n* **`course`**: Stores course definitions, including `course_id`, `title`, and `credits`.\n* **`takes`**: The central transaction table. An entry here signifies that a `student` has taken a `section`. It stores the `grade`.\n* **`department`**: Used for grouping students to calculate departmental performance.\n\n### 2. Core Logic and Functions\n\nThe logic is implemented in a series of layered views and functions.\n\n#### Helper Views and Functions (`src/02_grade_helpers.sql`)\n\n* **`udf_convert_grade_to_points(grade)`**: A simple, immutable function that converts a letter grade `VARCHAR` into a `NUMERIC` grade point. This is the single source of truth for all grade conversions.\n* **`v_student_grade_points`**: This is the foundational view. It joins `takes` and `course` and, for every row, calculates the `grade_points` (from the function above) and the `quality_points` (which is `grade_points * credits`). It also includes boolean flags `is_gpa_applicable` and `is_passed` for precise calculations.\n\n#### Core Analytical Views (`src/03_core_views.sql`)\n\n* **`v_student_academic_summary`**: This is the main engine for the transcript. It first calculates per-semester stats (total quality points and GPA-applicable credits). Then, it uses window functions to calculate the *running cumulative* quality points and credits. Finally, it joins this data back to the per-course view (`v_student_grade_points`) to create a complete row-by-row academic history, annotated with the correct `semester_gpa` and `cumulative_gpa` for that term.\n* **`v_student_overall_summary`**: This view provides a simple, one-row-per-student summary. It calculates the *final* `cumulative_gpa` and the `total_credits_earned` (based on `is_passed = true`).\n* **`v_department_performance`**: This view calculates a true, credit-weighted average GPA for each department by aggregating the `quality_points` and `credits` from *all* students in that department.\n\n#### Main Functions (`src/04_transcript_functions.sql`)\n\n* **`udf_generate_transcript(student_id)`**: This is a simple SQL function that acts as a clean API. It just `SELECT`s all relevant columns from the `v_student_academic_summary` view for a specific student, providing a ready-to-use transcript.\n* **`udf_get_deans_list(semester, year, min_gpa)`**: This function uses `DISTINCT ON (id, semester, year)` on the main summary view to get a single, definitive GPA for each student for each term, then filters them by the function parameters.\n\n---\n\n## Project Structure\n\n```\npostgres-academic-performance-analyzer/\n├── .gitignore                        # Ignores system and credential files\n├── LICENSE                           # MIT license file\n├── README.md                         # This documentation\n├── demo.sql                          # Example script showing how to use the system\n└── src/\n    ├── 00_schema.sql                 # Main DDL script to create all tables\n    ├── 01_data.sql                   # Script to insert sample data\n    ├── 02_grade_helpers.sql          # Creates grade conversion function and base view\n    ├── 03_core_views.sql             # Creates the main analytical/summary views\n    └── 04_transcript_functions.sql   # Creates the final report functions\n```\n\n## How to Use\n\n1.  **Setup Database:**\n    Create a new PostgreSQL database.\n    ```bash\n    createdb university_db\n    ```\n\n2.  **Connect to Database:**\n    Use `psql` or any SQL client to connect to your new database.\n    ```bash\n    psql university_db\n    ```\n\n3.  **Run SQL Scripts (in order):**\n    Execute the SQL scripts from the `src/` directory in numerical order.\n\n    ```sql\n    -- 1. Create the schema\n    \\i src/00_schema.sql\n    \n    -- 2. Load the sample data\n    \\i src/01_data.sql\n    \n    -- 3. Create helper views and functions\n    \\i src/02_grade_helpers.sql\n    \n    -- 4. Create the main analytical views\n    \\i src/03_core_views.sql\n    \n    -- 5. Create the final report functions\n    \\i src/04_transcript_functions.sql\n    ```\n\n4.  **Test the System:**\n    Run the `demo.sql` script to see the system in action. This script is wrapped in a `BEGIN...ROLLBACK` block, so it will not make permanent changes to your data.\n\n    ```sql\n    \\i demo.sql\n    ```\n    You will see output for each test case, for example:\n    ```\n     student_id |  name   |  dept_name  | total_credits_earned |   cumulative_gpa\n    ------------+---------+-------------+----------------------+----------------------\n     00128      | Zhang   | Comp. Sci.  |                    7 | 3.8571428571428571\n     12345      | Shankar | Comp. Sci.  |                   14 | 3.5000000000000000\n     45678      | Levy    | Physics     |                    7 | 2.5454545454545455\n    (3 rows)\n    ```\n\n## Example Function Call\n\nYou can call the functions directly at any time:\n\n```sql\n-- Generate a transcript for a specific student\nSELECT * FROM udf_generate_transcript('12345');\n\n-- Find students for the Dean's List\nSELECT * FROM udf_get_deans_list('Fall', 2017, 3.75);\n```\n\n---\n\n## Author\n\nFeel free to connect or reach out if you have any questions!\n\n* **Maryam Rezaee**\n* **GitHub:** [@msmrexe](https://github.com/msmrexe)\n* **Email:** [ms.maryamrezaee@gmail.com](mailto:ms.maryamrezaee@gmail.com)\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for full details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsmrexe%2Fpostgres-academic-performance-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsmrexe%2Fpostgres-academic-performance-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsmrexe%2Fpostgres-academic-performance-analyzer/lists"}