A MySQL database learning project built with Laravel framework to practice and demonstrate fundamental database concepts, SQL commands, and relational database design.
This project was created as an educational tool for learning database management using MySQL commands. It implements a university course registration system with proper relational design, demonstrating key database concepts including:
- Table creation and schema design
- Primary and foreign key constraints
- Relationships (One-to-Many, Many-to-Many)
- ENUM data types
- Unique constraints
- Cascade operations
- Timestamps and auto-updates
The system consists of five main tables:
dept_id- Primary Key (Auto Increment)dept_name- Unique department namelocation- Department location- Timestamps
instructor_id- Primary Key (Auto Increment)name- Instructor nameemail- Unique email addressdept_id- Foreign Key to Departments (CASCADE)- Timestamps
course_id- Primary Key (VARCHAR)title- Course titlecredits- Course credits (DECIMAL)dept_id- Foreign Key to Departments (CASCADE)instructor_id- Foreign Key to Instructors (SET NULL)- Timestamps
student_id- Primary Key (Auto Increment)name- Student nameemail- Unique email addressmajor- Student's majoryear- Academic year (ENUM: "1", "2", "3", "4", "Graduate")- Timestamps
reg_id- Primary Key (Auto Increment)student_id- Foreign Key to Students (CASCADE)course_id- Foreign Key to Courses (CASCADE)semester- Registration semestergrade- Course graderegistered_at- Registration timestamp- Unique constraint on (student_id, course_id, semester)
- Timestamps
- Department → Instructors: One-to-Many
- Department → Courses: One-to-Many
- Instructor → Courses: One-to-Many
- Student → Registrations: One-to-Many
- Course → Registrations: One-to-Many
- Students ↔ Courses: Many-to-Many (through Registrations)
- Framework: Laravel 11.x
- Database: MySQL
- Language: PHP 8.2+
- SQL: Raw MySQL commands via
DB::statement()
- PHP >= 8.2
- Composer
- MySQL >= 8.0
- Node.js & NPM (for assets)
-
Clone the repository
git clone <repository-url> cd course-registration
-
Install PHP dependencies
composer install
-
Install Node dependencies
npm install
-
Configure environment
cp .env.example .env php artisan key:generate
-
Update database configuration in
.envDB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=course_registration DB_USERNAME=your_username DB_PASSWORD=your_password -
Create the database
CREATE DATABASE course_registration;
-
Run migrations
php artisan migrate
-
Seed the database (optional)
php artisan db:seed
php artisan serveVisit http://localhost:8000 in your browser.
The migrations use raw SQL commands for educational purposes:
// Example: Creating departments table
DB::statement('
CREATE TABLE departments(
dept_id int auto_increment primary key,
dept_name varchar(100) not null unique,
location varchar(150),
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp on update current_timestamp
);
');php artisan migrate:fresh --seed-
DDL (Data Definition Language)
- CREATE TABLE
- ALTER TABLE
- DROP TABLE
- Primary Keys
- Foreign Keys
- Constraints
-
Data Types
- INT, VARCHAR, DECIMAL
- ENUM
- TIMESTAMP
- AUTO_INCREMENT
-
Constraints
- PRIMARY KEY
- FOREIGN KEY
- UNIQUE
- NOT NULL
- DEFAULT values
-
Referential Integrity
- ON DELETE CASCADE
- ON DELETE SET NULL
- ON UPDATE CASCADE
-
Relationships
- One-to-Many
- Many-to-Many
- Junction tables
database/
├── migrations/ # Raw SQL table creation scripts
│ ├── create_departments_table.php
│ ├── create_instructors_table.php
│ ├── create_courses_table.php
│ ├── create_students_table.php
│ └── create_registrations_table.php
├── seeders/ # Sample data population
└── factories/ # Data factories
app/Models/ # Eloquent ORM models
├── Department.php
├── Instructor.php
├── Course.php
├── Student.php
└── Registration.php
Through this project, you can learn:
- How to design a normalized relational database
- Writing raw MySQL DDL commands
- Understanding foreign key relationships and cascade operations
- Implementing many-to-many relationships
- Using constraints to maintain data integrity
- Working with timestamps and auto-generated values
This is an educational project created for learning purposes.
Created as a database learning project for Academic Course 3-1
In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.
The Laravel framework is open-sourced software licensed under the MIT license.