https://github.com/ani811625/csi-assignment4
πThis repository contains the complete solution to the problem statement, assigned as part of the Week 4 deliverables during the Summer Internship Program at Celebal Technologies.
https://github.com/ani811625/csi-assignment4
microsoft-sql-server sql
Last synced: 12 months ago
JSON representation
πThis repository contains the complete solution to the problem statement, assigned as part of the Week 4 deliverables during the Summer Internship Program at Celebal Technologies.
- Host: GitHub
- URL: https://github.com/ani811625/csi-assignment4
- Owner: Ani811625
- Created: 2025-06-28T06:34:04.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-28T06:48:50.000Z (12 months ago)
- Last Synced: 2025-06-28T07:33:58.547Z (12 months ago)
- Topics: microsoft-sql-server, sql
- Language: TSQL
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π Open Elective Subject Allocation System (SQL Project)
This project implements an **automated subject allocation system** for students based on their GPA and subject preferences. It ensures fair and optimized distribution of elective subjects, considering seat availability and student priorities.
---
## π Objective
To develop a SQL-based system where:
- Each student submits 5 elective subject preferences.
- Subjects are allotted based on **descending GPA**.
- If a subject is full, the next preference is checked.
- If none are available, the student is marked as **unallotted**.
---
## π οΈ Tech Stack
| Technology | Purpose |
|------------|------------------------|
| SQL Server | Database & procedures |
| T-SQL | Logic implementation |
---
## π Database Schema
| Table Name | Columns | Description |
|--------------------|---------------------------------------------|-----------------------------------------------------------------------------|
| `StudentDetails` | `StudentId`, `StudentName`, `GPA`, `Branch`, `Section` | Contains student academic info |
| `SubjectDetails` | `SubjectId`, `SubjectName`, `MaxSeats`, `RemainingSeats` | Stores all elective subject details and seat availability |
| `StudentPreference`| `StudentId`, `SubjectId`, `Preference` | Maps students to their 5 subject preferences (1 = highest priority) |
| `Allotments` | `SubjectId`, `StudentId` | Final allotted subject for each student |
| `UnallotedStudents`| `StudentId` | Students who couldn't be allotted any subject from their preference list |
---
## π Setup Instructions
1. **Create the schema**
Execute the SQL scripts in the following order:
- `CREATE TABLE` statements for all 5 tables
- `INSERT INTO` statements for student/subject/preference data
2. **Create stored procedure**
Run `AllocateOpenElectives` procedure code.
3. **Execute allocation**
```sql
EXEC AllocateOpenElectives;
```
4. **View results**
```sql
SELECT * FROM Allotments;
SELECT * FROM UnallotedStudents;
```
---
## βοΈ Allocation Logic
1. Sort all students by **GPA descending**.
2. For each student:
- Check their subject preferences one by one (1 to 5).
- If a subject has available seats:
- Allot that subject.
- Decrease its `RemainingSeats`.
- If all preferences are full, mark student as **unallotted**.
---
## π₯ Sample Output
### β
Allotted Students
| SubjectId | StudentId |
|-----------|-------------|
| PO1491 | 159103041 |
| PO1491 | 159103036 |
| PO1492 | 159103039 |
| PO1492 | 159103038 |
| PO1492 | 159103040 |
| PO1492 | 159103037 |
### β Unallotted Students
> (Empty if all got subjects β populated if some couldnβt be allotted any)
---
## π Files/Folders in This Repo
| File/Folders | Description |
|----------------------------------------|---------------------------------------------|
| `Queries` | All Sql commands/queries |
| `Output` | Output of all Sql queries/commands |
| `Student Allotment SQL Problem.pdf` | The `Problem Statement` for the Week 4 |
| `README.md` | This documentation |
---
## π¨βπ» Developed By
**Aniruddha Sarkar**
_Student, B.Tech CSE (Cyber Security)_
_Techno Main Salt Lake_