A comprehensive Java-based database management system for educational institutions, demonstrating object-oriented programming principles through multi-level inheritance, file I/O operations, and a full-featured menu-driven interface.
- Overview
- Features
- Class Structure
- Getting Started
- Usage
- Technical Highlights
- What I Learned
- Future Enhancements
- Author
This project implements a school database management system that manages courses, faculty, students, and general staff through a hierarchical class structure. Built as part of CMP 158 at Lehman College, it demonstrates core computer science concepts including inheritance, polymorphism, file I/O, and exception handling.
- 7 Classes with inheritance relationships
- 3-Level Inheritance Hierarchy
- 15 CRUD Operations via menu interface
- ~1,600 Lines of Code
- 100% Functional with comprehensive error handling
- β Create and manage courses, faculty, students, and general staff
- β Add courses to faculty teaching schedules
- β Enroll students in courses and track credits
- β Query system for specific faculty, students, or courses
- β Find min/max values (courses, credits, teaching loads)
- β Persistent data storage via file I/O
- β Menu-driven console interface with 15 operations
- β
Custom sorting via
Comparableinterface implementation - β
Object equality checking with overridden
equals()methods - β
Formatted output via
toString()overrides - β Exception handling for file operations
- β Defensive programming with boundary checks
- β Static variable tracking for auto-generated IDs
Person (Base Class)
βββ Employee
β βββ Faculty
β βββ GeneralStaff
βββ Student
Course (Standalone - implements Comparable<Course>)
- Stores: name, birthYear
- Implements:
Comparable<Person> - Compares by: birthYear
- Stores: deptName, employeeID (auto-generated)
- Implements: inherited
Comparable - Compares by: employeeID
- Tracks: total number of employees (static)
- Stores: major, isGraduate, studentID (auto-generated), coursesTaken (ArrayList)
- Implements: inherited
Comparable - Compares by: total credits earned
- Tracks: total number of students (static)
- Stores: isTenured, coursesTaught (ArrayList)
- Implements: inherited
Comparable - Compares by: number of courses taught
- Max capacity: 100 courses
- Stores: duty (job responsibility)
- Implements: inherited
Comparable - Inherits comparison from Employee
- Stores: isGraduateCourse, courseDept, courseNum, numCredits
- Implements:
Comparable<Course> - Compares by: courseNum
- Java Development Kit (JDK) 8 or higher
- Any Java IDE (IntelliJ IDEA, Eclipse, VS Code) or command line
- Clone the repository
git clone https://github.com/FidelAP-19/School-Database-System.git
cd School-Database-System- Compile the project
javac *.java- Run the application
java MainCreate a file named SchoolDB_Initial.txt with the following format:
Course: true,777,CMP,4
Faculty: John Smith,1980,Computer Science,true
Student: Jane Doe,2000,Computer Science,false
GeneralStaff: Bob Johnson,1975,Facilities,Maintenance
Format Rules:
- Each line starts with object type:
Course:,Faculty:,Student:, orGeneralStaff: - Fields are comma-separated
- Boolean values:
trueorfalse
When you run the program, you'll see a menu with 15 operations:
=== MENU ===
1. Create 3 New Courses
2. Create 3 New Faculty
3. Create 3 New General Staff
4. Create 3 New Students
5. Add 2 Courses to Faculty
6. Add 2 Courses to Student
7. Add Array of 2 Courses to Faculty
8. Add Array of 2 Courses to Student
9. Get Course from Faculty by Index
10. Get Course from Student by Index
11. Query Faculty for Course
12. Faculty with Most/Least Courses
13. Find Min/Max Course
14. Student with Most/Least Credits
15. Display All Data
0. Exit and Save
Creating a New Course:
Enter choice: 1
--- Enter 3 New Courses ---
Course 1:
Are you a Graduate course? (true/false): false
Enter Course Number: 168
Enter Course Department: CMP
Enter Number of Credits: 4
Adding Courses to a Student:
Enter choice: 6
Which student? (Enter index): 0
Which course? (Enter index): 0
Course added successfully!
- 3-level deep inheritance demonstrating class relationships
- Proper use of
super()for parent class initialization - Method overriding for specialized behavior
// Collections can hold parent type with child objects
ArrayList<Person> people = new ArrayList<>();
people.add(new Student("Alice", 2000, "CS", false));
people.add(new Employee("Bob", 1985, "IT"));- All fields are
private - Public getters/setters for controlled access
- Defensive copying where appropriate
private ArrayList<Course> coursesTaught; // Faculty's courses
private ArrayList<Course> coursesTaken; // Student's coursesBenefits:
- Dynamic sizing (no fixed array limits)
- Built-in methods (
add,get,size) - Type safety with generics
try {
FileInputStream fbs = new FileInputStream("SchoolDB_Initial.txt");
Scanner inFS = new Scanner(fbs);
// Process file...
inFS.close();
} catch (FileNotFoundException e) {
System.out.println("Cannot find file");
} catch (IOException e) {
System.out.println("Error reading file");
}@Override
public int compareTo(Student other) {
int thisCreditTotal = calculateTotalCredits();
int otherCreditTotal = other.calculateTotalCredits();
if (thisCreditTotal > otherCreditTotal) return 1;
if (thisCreditTotal < otherCreditTotal) return -1;
return 0;
}Boundary Checking:
public Course getCourseTaken(int index) {
if (index < 0 || index >= coursesTaken.size()) {
return null; // Safe return instead of crash
}
return coursesTaken.get(index);
}Capacity Limits:
public void addCourseTaught(Course course) {
if (coursesTaught.size() < 100) { // Prevent overflow
coursesTaught.add(course);
}
}public class Student extends Person {
static private int numStudents = 0; // Shared across all instances
private int studentID;
public Student() {
numStudents++; // Increment counter
studentID = numStudents; // Auto-generate unique ID
}
}- β Multi-level Inheritance - Building complex class hierarchies
- β Polymorphism - Using parent types to reference child objects
- β Encapsulation - Protecting data with private fields and public methods
- β Abstraction - Separating interface from implementation
- β Comparable Interface - Custom sorting logic
- β
Method Overriding -
equals(),toString(),compareTo() - β ArrayList Collections - Dynamic data structures
- β File I/O - Reading/writing persistent data
- β Exception Handling - Graceful error recovery
- β Static vs Instance - Understanding class-level vs object-level data
- β Code Organization - Logical class structure
- β Defensive Programming - Null checks, boundary validation
- β User Input Validation - Preventing invalid data
- β Documentation - Clear comments and method signatures
- β String Parsing - Converting file data to objects
- β Data Validation - Ensuring data integrity
- β Menu-Driven Architecture - Building interactive applications
- β Algorithm Design - Finding min/max, calculating totals
Course: CMP 158 - Programming Methods II
Institution: Lehman College, City University of New York (CUNY)
Semester: Fall 2024
This project served as the capstone assignment, demonstrating mastery of:
- Object-oriented programming principles
- Java collections framework
- File I/O and exception handling
- Software design and architecture
School-Database-System/
βββ Person.java # Base class for all people
βββ Employee.java # Base class for employees
βββ Student.java # Student class with course tracking
βββ Faculty.java # Faculty with teaching assignments
βββ GeneralStaff.java # General staff with duties
βββ Course.java # Course information
βββ Main.java # Entry point (basic version)
βββ Driver_SchoolDB.java # Full menu-driven application
βββ SchoolDB_Initial.txt # Sample input data
βββ README.md # This file
This is an educational project, but feedback and suggestions are welcome!
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/improvement) - Open a Pull Request
This project is open source and available under the MIT License.
Fidel Perez
- GitHub: @FidelAP-19
- LinkedIn: Fidel Perez
- Portfolio: fidelperez.dev
- Institution: Lehman College, City University of New York (CUNY)
- Course: Programming Methods II
β If you found this project helpful or interesting, please consider giving it a star!
Built with β and dedication to learning software engineering