Capstone Project 2

Student Database System

Build a complete student records management system in C. You will implement file handling for persistent storage, use structures for data organization, create CRUD operations (Create, Read, Update, Delete), and add search, sort, and reporting capabilities with proper data validation and error handling.

12-18 hours
Intermediate
450 Points
What You Will Build
  • Student record structures
  • Binary file storage system
  • CRUD operations module
  • Search and sort algorithms
  • Interactive menu-driven CLI
Contents
01

Project Overview

This capstone project brings together everything you have learned about file handling, structures, and data management in C. You will work with the NED University Student Academic Records dataset from Kaggle containing 3,500+ student records with fields including student ID, roll number, department, batch year, and 20,000+ GPA results across 14 semesters. Your goal is to build a professional-grade database management system that handles persistent storage using binary files, implements efficient search and sort algorithms, and provides a user-friendly command-line interface for all CRUD operations.

Skills Applied: This project tests your proficiency in structures, file I/O (binary and text), dynamic memory allocation, arrays, pointers, sorting algorithms, and building modular C programs with proper header files and separate compilation.
Structures

Design data structures for student records and courses

File I/O

Binary and text file handling for persistent storage

Algorithms

Search and sort algorithms for data retrieval

CLI Interface

Menu-driven command-line user interface

Learning Objectives

Technical Skills
  • Design and implement complex structures with nested types
  • Master binary file I/O with fread() and fwrite()
  • Implement efficient search algorithms (linear, binary)
  • Apply sorting algorithms to structure arrays
  • Build modular programs with header files
Professional Skills
  • Design database schemas and data models
  • Implement data validation and error handling
  • Create user-friendly command-line interfaces
  • Write maintainable and well-documented code
  • Test with edge cases and handle errors gracefully
Ready to submit? Already completed the project? Submit your work now!
Submit Now
02

Project Scenario

TechVarsity University

You have been hired as a Software Developer at TechVarsity University, a growing educational institution with over 500 enrolled students across multiple departments. The registrar's office currently manages student records using spreadsheets, which has become unmanageable as the student body grows. The IT department needs a robust, command-line based student database system that can be deployed on the university's Linux servers.

"We need a reliable system to manage student records - add new students, update their information, track their courses and grades, and generate reports. The system must store data persistently and be fast enough to search through hundreds of records instantly. Can you build this for us?"

Dr. Sarah Mitchell, Dean of Student Affairs

System Requirements from the Client

Student Management
  • Add new student records with validation
  • View individual student details
  • Update student information
  • Delete student records (with confirmation)
Search and Filter
  • Search by student ID (exact match)
  • Search by name (partial match)
  • Filter by department or status
  • Filter by GPA range
Sorting and Reports
  • Sort by name, ID, GPA, or enrollment date
  • List all students (paginated)
  • Generate department-wise statistics
  • Export data to CSV format
Data Persistence
  • Store all records in binary file
  • Auto-save after each modification
  • Backup and restore functionality
  • Import from CSV file
Pro Tip: Think modularly! Separate your code into logical units: student.c (structure operations), fileio.c (file handling), search.c (search/sort), and menu.c (user interface). This makes testing and debugging much easier.
03

The Dataset

You will work with a comprehensive relational student database from Kaggle. Download the 4 CSV files containing student records, results, departments, and semesters to test your implementation:

Dataset Download

Download the sample dataset files based on the NED University Student Academic Records structure. Contains 4 relational CSV files with foreign key relationships.

Full Dataset from Kaggle

This project is based on the NED University Student Academic Records (2018-25) dataset from Kaggle. For the complete dataset with 3,500+ students and 20,000+ results, download from Kaggle:

Full Dataset: 4 CSV files | 3,500+ students, 20,000+ results, 12 departments, 14 semesters | Relational structure with foreign keys for CRUD operations | License: CC BY-SA 4.0
Dataset Schema
Relational Schema:
departments (1) ──< students (N)
                        │
                        └──< results (N) >── semesters (1)

ColumnTypeDescription
idIntegerPrimary Key - Unique student identifier
roll_numberStringUnique roll number (e.g., CS-21001)
department_idIntegerForeign Key → departments.id
batch_yearIntegerYear of admission (2018-2023)

ColumnTypeDescription
idIntegerResult record identifier
student_idIntegerForeign Key → students.id
semester_idIntegerForeign Key → semesters.id
gpaFloatGPA for semester (0.00-4.00)
semester_numIntegerProgressive semester number (1, 2, 3...)

ColumnTypeDescription
idIntegerPrimary Key - Department identifier
nameStringFull department name (e.g., "Computer Science")
codeStringDepartment code (e.g., "CS", "SE", "AI")

ColumnTypeDescription
idIntegerPrimary Key - Semester identifier
yearIntegerAcademic year (e.g., 2021, 2022)
sessionStringSession type ("Spring" or "Fall")
Sample Dataset: 100 students, 100 results, 12 departments, 14 semesters
Relationships: 3 Foreign Keys linking all tables
Sample Data Preview

Here is sample data from each of the 4 relational tables:

students.csv
idroll_numberdepartment_idbatch_year
1CS-1800112018
36CS-2100112021
47AI-2100142021
results.csv
idstudent_idsemester_idgpasemester_num
1113.451
653673.721
663683.782
departments.csv
idnamecode
1Computer ScienceCS
2Software EngineeringSE
4Artificial IntelligenceAI
semesters.csv
idyearsession
12018Fall
72021Fall
142025Spring
Data Handling: Your database system should parse all 4 CSV files and maintain referential integrity using foreign keys. Implement validation for GPA ranges (0.00-4.00) and enforce foreign key constraints in CRUD operations.
04

Key Concepts

Before diving into the implementation, understand these fundamental concepts that power your student database system. These concepts are essential for building a robust and efficient data management application.

Data Structures
  • Date Structure: Store day, month, year components
  • Student Structure: 13 fields including ID, name, email, phone, DOB, gender, department, enrollment date, GPA, credits, status, address
  • StudentDB Structure: Dynamic array, count, capacity, filename
  • Memory Management: Dynamic allocation with malloc/realloc
  • Array Expansion: Double capacity when full
  • Proper Cleanup: Free all allocated memory on exit
File I/O Operations
  • Binary Write: fwrite() for structures to .dat file
  • Binary Read: fread() to load records from .dat file
  • CSV Import: Parse comma-separated values with validation
  • CSV Export: Generate properly formatted CSV output
  • Backup System: Create timestamped backup copies
  • Error Handling: Check file operations for failures
Search Algorithms
  • Binary Search: O(log n) lookup by student ID (requires sorted data)
  • Linear Search: Name search with partial matching
  • Filter Functions: By department, GPA range, status
  • Case-Insensitive: Match regardless of capitalization
  • Multiple Results: Return array of matching records
  • Efficient Indexing: Maintain sorted order for fast lookups
Sorting Algorithms
  • qsort() Function: Standard library quicksort
  • Comparator Functions: Custom compare for each field
  • Sort by ID: Numeric ascending/descending
  • Sort by Name: Alphabetical by last name, first name
  • Sort by GPA: Highest to lowest ranking
  • Sort by Date: Chronological enrollment order
Project Structure
include/
  • student.h - Structure definitions
  • database.h - Database operations
  • fileio.h - File I/O functions
  • search.h - Search and sort
  • menu.h - Menu interface
src/
  • student.c - CRUD operations
  • database.c - DB management
  • fileio.c - Read/write operations
  • search.c - Search algorithms
  • menu.c - User interface
  • main.c - Entry point
Other Files
  • data/ - Sample CSV data
  • tests/ - Unit test files
  • Makefile - Build config
  • README.md - Documentation
Your Task: Implement all the functions across the source files. Start with the structure definitions, then file I/O, then CRUD operations, and finally the menu interface. Test each component before integrating.
05

Project Requirements

Complete all components below to build a fully functional student database system. Each step builds upon the previous one, taking you from basic data structures to a complete interactive application.

1
Data Structures

Structure Definitions (student.h):

  • Define Date structure for date handling
  • Define Student structure with all 13 fields
  • Define StudentDB structure for database management
  • Define constants: MAX_STUDENTS, MAX_NAME_LEN, etc.

Validation Functions (student.c):

  • validate_student() - Check all fields are valid
  • validate_email() - Email format validation
  • validate_gpa() - GPA in range 0.0-4.0
  • validate_date() - Date is valid and reasonable
Deliverable: Complete header files with all structure definitions and student.c with validation functions. All validation should return error codes.
2
File I/O Operations

Binary File Operations (fileio.c):

  • save_database() - Write all records to binary file
  • load_database() - Read all records from binary file
  • backup_database() - Create timestamped backup copy
  • restore_database() - Restore from backup file

CSV Import/Export (fileio.c):

  • import_from_csv() - Parse CSV and add records
  • export_to_csv() - Export all records as CSV
  • Handle quoted fields, escaped commas, and newlines
  • Report import errors with line numbers
Deliverable: Complete fileio.c with binary and CSV operations. Test with the provided students.csv file to ensure correct parsing.
3
CRUD Operations

Create Operations (database.c):

  • db_init() - Initialize empty database
  • db_add_student() - Add new student with validation
  • Generate unique student ID if not provided
  • Auto-expand array when capacity is reached

Read Operations (database.c):

  • db_get_by_id() - Get student by ID
  • db_get_all() - Get all students (paginated)
  • db_count() - Get total student count
  • db_get_by_department() - Filter by department

Update and Delete (database.c):

  • db_update_student() - Update existing record
  • db_delete_student() - Remove record by ID
  • db_free() - Free all allocated memory
Deliverable: Complete database.c with all CRUD operations. Each operation should validate input and return appropriate error codes.
4
Search and Sort

Search Algorithms (search.c):

  • search_by_id() - Binary search by student ID
  • search_by_name() - Partial match name search
  • search_by_email() - Exact email match
  • filter_by_gpa_range() - Filter by GPA min/max
  • filter_by_status() - Filter by enrollment status

Sort Algorithms (search.c):

  • sort_by_id() - Sort ascending/descending by ID
  • sort_by_name() - Alphabetical sort by last name
  • sort_by_gpa() - Sort by GPA (highest first)
  • sort_by_date() - Sort by enrollment date
  • Use qsort() with custom comparator functions
Deliverable: Complete search.c with all search and sort functions. Binary search requires sorted data - maintain sorted order after insertions.
5
Menu Interface

Main Menu (menu.c):

  • Display numbered menu options
  • Read user choice with input validation
  • Clear screen between operations (optional)
  • Handle invalid input gracefully

Menu Options (11 items): Add, View, Search, Update, Delete, List All, Sort, Reports, Import CSV, Export CSV, Backup, Exit

Sub-menus:

  • Search menu: By ID, name, department, GPA range, status
  • Sort menu: By ID, name, GPA, enrollment date
  • Report menu: Department statistics, GPA distribution
Deliverable: Polished menu.c with complete menu system, all operations working, input validation, and user-friendly prompts and messages.
6
Reports and Statistics

Statistics Functions:

  • report_total_count() - Total students
  • report_by_department() - Count per department
  • report_by_status() - Count by status
  • report_gpa_stats() - Avg, min, max GPA
  • report_gpa_distribution() - GPA ranges histogram

Output Format: Clear tabular display with headers, aligned columns, totals, and averages. Include department names, student counts, and calculated GPA statistics.

Deliverable: Report functions integrated with menu system. All statistics calculated correctly with formatted output.
Development Tip: Implement and test each module individually. Use a test file (test_database.c) to verify each function works correctly before integrating into the menu system.
06

Example Usage

Your student database system should provide a clear, menu-driven interface. Below are the expected features and sample workflows for each major operation.

Main Menu Options
  1. Add New Student
  2. View Student by ID
  3. Search Students
  4. Update Student
  5. Delete Student
  6. List All Students
  7. Sort Students
  8. Generate Report
  9. Import from CSV
  10. Export to CSV
  11. Backup Database
  12. Exit
Student Details Display

When viewing a student, display:

  • Student ID and Full Name
  • Email and Phone Number
  • Date of Birth and Gender
  • Department Name
  • Enrollment Date
  • Current GPA and Credits Completed
  • Enrollment Status
  • Full Address
Search Menu Options
  • Search by ID: Exact match, instant result
  • Search by Name: Partial match, multiple results
  • Search by Department: List all in department
  • Filter by GPA Range: Min and max GPA input
  • Filter by Status: Active, Graduated, On Leave, Suspended
Reports Menu Options
  • Department Statistics: Count and avg GPA per dept
  • GPA Distribution: Histogram of GPA ranges
  • Status Summary: Count by enrollment status
  • Top 10 Students: Highest GPA ranking
Test Cases for Validation
OperationInputExpected Result
Add StudentValid dataNew ID assigned, record saved
Add StudentDuplicate IDError: ID already exists
Add StudentInvalid emailError: Invalid email format
Add StudentGPA = 4.5Error: GPA must be 0.0-4.0
Search by ID10001Emily Johnson record displayed
Search by ID99999Error: Student not found
Search by name"john"All students with "john" in name
Filter GPA3.5 to 4.0List of honor students
Delete10001 + confirmRecord deleted, auto-save
Delete10001 + cancelNo change, operation cancelled
Export CSVoutput.csvAll records exported
Import CSVstudents.csv500 records imported
07

Submission Requirements

Create a public GitHub repository with the exact name shown below:

Required Repository Name
c-student-database
github.com/<your-username>/c-student-database
Required Project Structure
include/
  • student.h
  • database.h
  • fileio.h
  • search.h
  • menu.h
src/
  • student.c
  • database.c
  • fileio.c
  • search.c
  • menu.c
  • main.c
Other
  • data/ (students.csv)
  • tests/ (test files)
  • Makefile
  • README.md
README.md Required Sections
1. Project Header
  • Project title and description
  • Your full name and submission date
  • Course and project number
2. Features
  • List of all CRUD operations
  • Search and sort capabilities
  • File I/O features (binary, CSV)
3. Build Instructions
  • Prerequisites (GCC, make)
  • How to compile with make
  • How to run the program
4. Usage Examples
  • Menu navigation guide
  • Sample operations with output
  • Screenshots of terminal output
5. Data Structures
  • Student structure description
  • Database structure description
  • File format documentation
6. Testing
  • How to run test cases
  • Test coverage description
  • Edge cases handled
7. Challenges and Solutions
  • Difficulties encountered
  • How you solved them
  • What you learned
8. Contact
  • GitHub profile link
  • LinkedIn (optional)
  • Email (optional)
Do Include
  • All source files (.c) and headers (.h)
  • Working Makefile with all targets
  • Sample data file (students.csv)
  • Test file with unit tests
  • Screenshots showing functionality
  • Complete README with all sections
Do Not Include
  • Compiled binaries or object files (*.o, *.exe)
  • Binary database files (*.dat)
  • IDE-specific files (.vscode/, .idea/)
  • Temporary or backup files
  • Plagiarized code from online sources
Important: Before submitting, verify that your code compiles without warnings using gcc -Wall -Wextra and all menu operations work correctly. Test with valgrind to ensure no memory leaks.
Submit Your Project

Enter your GitHub username - we will verify your repository automatically

08

Grading Rubric

Your project will be graded on the following criteria. Total: 450 points.

Criteria Points Description
Data Structures 50 Proper structure design, validation functions, memory management
File I/O 75 Binary file operations, CSV import/export, backup/restore
CRUD Operations 100 All create, read, update, delete operations working correctly
Search and Sort 75 Multiple search methods, sorting by different fields
User Interface 50 Menu system, input validation, user-friendly messages
Reports 50 Statistics, formatted output, department reports
Code Quality 25 Modular design, comments, no memory leaks, warnings
Documentation 25 README quality, screenshots, build instructions
Total 450
Grading Levels
Excellent
405-450

Exceeds all requirements with exceptional quality

Good
338-404

Meets all requirements with good quality

Satisfactory
270-337

Meets minimum requirements

Needs Work
< 270

Missing key requirements

Ready to Submit?

Make sure you have completed all requirements and reviewed the grading rubric above.

Submit Your Project
09

Pre-Submission Checklist

Use this checklist to verify you have completed all requirements before submitting your project.

Data Structures
File I/O
CRUD Operations
Repository Requirements
Final Check: Run your program, import the provided students.csv, perform several operations (add, search, update, delete), export to CSV, and verify the exported data is correct.
10

Common Issues and Solutions

Encountering problems? Here are the most common issues students face and how to resolve them quickly.

Segmentation Fault on Load
Problem

Program crashes when loading database file

Solution

Ensure you allocate memory before reading records:

db->students = malloc(db->count * sizeof(Student));
Tip: Always check if file exists and malloc succeeds
CSV Parsing Errors
Problem

Names with commas break CSV parsing

Solution

Handle quoted fields properly. If a field starts with a quote, read until closing quote:

if (line[i] == '"') { /* Read until next quote */ }
Note: Use strtok() carefully - it modifies the string
Binary Search Not Finding Records
Problem

Binary search returns NULL even for existing records

Solution

Binary search requires sorted data. Sort by ID before searching:

qsort(db->students, db->count, sizeof(Student), compare_by_id);
Debug: Print first 5 IDs to verify sort order
Input Buffer Issues
Problem

scanf() skips input or leaves newline in buffer

Solution

Clear input buffer after scanf() or use fgets() for strings:

while (getchar() != '\n'); // Clear buffer
Prevention: Use fgets() + sscanf() for safer input
Still Having Issues?

Check the course discussion forum or reach out for help