A Database Management Systems (DBMS) Course Project demonstrating Polyglot Persistence using MySQL and MongoDB
- Project Overview
- Why Both Databases?
- Features
- Tech Stack
- Architecture
- Database Schemas
- Setup Instructions
- API Documentation
- Project Structure
- Demo Credentials
- ER Diagram
- Future Enhancements
The Hybrid Student Learning Portal is a full-stack web application that demonstrates the concept of polyglot persistence by strategically using both relational (MySQL) and NoSQL (MongoDB) databases in a single system.
This project showcases:
- When and why to use different database paradigms
- Integration of MySQL and MongoDB in a unified backend
- Real-world application of DBMS concepts (normalization, joins, indexing, etc.)
- RESTful API design with Express.js
- Full authentication and authorization flow
Used for:
- โ Users - Strong consistency, authentication
- โ Courses - Relationships with instructors
- โ Enrollments - Many-to-many relationships, foreign keys
- โ Quizzes & Submissions - Marks, grades, aggregations (AVG, SUM)
Why?
- ACID transactions ensure data integrity
- Complex JOINs for enrollment and performance queries
- Foreign key constraints prevent orphaned data
- Perfect for numerical data and aggregations
Used for:
- โ Discussions - Nested posts/comments (embedded documents)
- โ Assignments - Submissions with varying fields (file/link/text)
- โ Activity Logs - High-volume, time-series data
Why?
- Flexible schema for varying submission types
- Better performance for nested/hierarchical data
- Horizontal scalability for high-volume logs
- No need for complex JOINs for embedded data
โ User Management
- Registration with role selection (Student/Instructor/Admin)
- JWT-based authentication
- Profile management
โ Course Management
- Browse all courses
- View course details
- Create courses (Instructor/Admin)
- Enrollment system with duplicate prevention
โ Quiz System (MySQL)
- Create quizzes for courses
- Submit quiz answers
- View marks and performance
- Aggregate statistics (average, min, max)
โ Activity Logging (MongoDB)
- Automatic logging of all user actions
- Track logins, enrollments, views, submissions
- Analytics and reporting capabilities
๐ MySQL Concepts
- Primary Keys, Foreign Keys, Unique Constraints
- One-to-Many, Many-to-Many relationships
- Complex JOINs (INNER, LEFT)
- Aggregation functions (COUNT, AVG, ROUND)
- Subqueries
- Views
- Stored Procedures
- Transactions
- Indexing
๐ MongoDB Concepts
- Document-oriented storage
- Embedded vs Referenced documents
- Compound indexes
- Aggregation pipelines
- Flexible schema design
- Time-series optimization
- Runtime: Node.js
- Framework: Express.js
- MySQL: mysql2 (with connection pooling)
- MongoDB: Mongoose
- Authentication: JWT (jsonwebtoken)
- Password Hashing: bcryptjs
- HTML5, CSS3, Vanilla JavaScript
- Simple, minimal UI focusing on API demonstration
- dotenv (environment management)
- nodemon (development server)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Frontend (Browser) โ
โ HTML/CSS/JavaScript (SPA-like) โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP/REST API
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Express.js Backend Server โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Routes & Controllers Layer โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Middleware (Auth, Logging) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ
โ MySQL โ โ MongoDB โ
โโโโโโโโโโโโโโโโโค โโโโโโโโโโโโโโโโโค
โ โข users โ โ โข discussions โ
โ โข courses โ โ โข assignments โ
โ โข enrollments โ โ โข activity_ โ
โ โข quizzes โ โ logs โ
โ โข quiz_ โ โโโโโโโโโโโโโโโโโ
โ submissions โ
โโโโโโโโโโโโโโโโโ
user_id (PK, AUTO_INCREMENT)
name
email (UNIQUE)
password_hash
role (ENUM: student, instructor, admin)
created_atcourse_id (PK, AUTO_INCREMENT)
course_code (UNIQUE)
course_name
description
instructor_id (FK โ users.user_id)
created_atenrollment_id (PK, AUTO_INCREMENT)
student_id (FK โ users.user_id)
course_id (FK โ courses.course_id)
enrolled_at
status (ENUM: active, dropped, completed)
UNIQUE (student_id, course_id)quiz_id (PK, AUTO_INCREMENT)
course_id (FK โ courses.course_id)
title
max_marks
due_datesubmission_id (PK, AUTO_INCREMENT)
quiz_id (FK โ quizzes.quiz_id)
student_id (FK โ users.user_id)
marks_obtained
submitted_at{
course_id: Number, // References MySQL course_id
title: String,
created_by: Number, // References MySQL user_id
posts: [
{
post_id: Number,
user_id: Number,
content: String,
created_at: Date
}
]
}{
course_id: Number,
assignment_title: String,
description: String,
due_date: Date,
max_marks: Number,
submissions: [
{
student_id: Number,
submitted_at: Date,
submission_type: String, // file, link, or text
file_path: String,
grade: Number,
feedback: String
}
]
}{
user_id: Number,
action: String, // LOGIN, VIEW_COURSE, ENROLL_COURSE, etc.
course_id: Number,
timestamp: Date,
metadata: {
ip_address: String,
browser: String,
os: String
}
}- Node.js (v14 or higher)
- MySQL (v8.0 or higher)
- MongoDB (v5.0 or higher)
# Navigate to project directory
cd student-education-platform-Database-Management-System-Project-
# Install dependencies
npm install# Login to MySQL
mysql -u root -p
# Run the schema file
source database/mysql/schema.sql
# Or on Windows:
mysql -u root -p < database/mysql/schema.sql# Start MongoDB service (if not running)
net start MongoDB
# MongoDB will automatically create the database on first connection# Copy example env file
copy .env.example .env
# Edit .env with your credentials
# Use notepad or any text editor
notepad .envUpdate these values in .env:
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=your_mysql_password
MYSQL_DATABASE=student_portal
MONGODB_URI=mongodb://localhost:27017/student_portal
PORT=3000
JWT_SECRET=your_secret_key_change_this# Test database connections
npm run init-db
# Start the server
npm start
# Or use development mode with auto-reload
npm run devOpen your browser and navigate to:
- Frontend: http://localhost:3000
- API Documentation: http://localhost:3000/api
POST /api/auth/register
Content-Type: application/json
{
"name": "John Doe",
"email": "[email protected]",
"password": "password123",
"role": "student"
}POST /api/auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "password123"
}GET /api/auth/me
Authorization: Bearer <token>GET /api/coursesGET /api/courses/:id
Authorization: Bearer <token> (optional)POST /api/courses
Authorization: Bearer <token>
Content-Type: application/json
{
"course_code": "CS101",
"course_name": "Introduction to CS",
"description": "Course description"
}POST /api/courses/:id/enroll
Authorization: Bearer <token>GET /api/courses/my/courses
Authorization: Bearer <token>student-education-platform-Database-Management-System-Project-/
โ
โโโ database/
โ โโโ mysql/
โ โโโ schema.sql # MySQL table definitions & sample data
โ โโโ queries.sql # Sample queries & views
โ
โโโ src/
โ โโโ config/
โ โ โโโ mysql.js # MySQL connection pool
โ โ โโโ mongodb.js # MongoDB connection
โ โ
โ โโโ models/
โ โ โโโ Discussion.js # Mongoose model
โ โ โโโ Assignment.js # Mongoose model
โ โ โโโ ActivityLog.js # Mongoose model
โ โ
โ โโโ controllers/
โ โ โโโ authController.js # Auth logic
โ โ โโโ courseController.js # Course logic
โ โ
โ โโโ routes/
โ โ โโโ authRoutes.js # Auth endpoints
โ โ โโโ courseRoutes.js # Course endpoints
โ โ
โ โโโ middleware/
โ โ โโโ auth.js # JWT verification
โ โ โโโ activityLogger.js # MongoDB logging
โ โ
โ โโโ scripts/
โ โ โโโ initDatabase.js # DB initialization
โ โ
โ โโโ server.js # Express app entry point
โ
โโโ public/
โ โโโ index.html # Frontend HTML
โ โโโ styles.css # Frontend CSS
โ โโโ app.js # Frontend JavaScript
โ
โโโ .env.example # Environment template
โโโ .gitignore
โโโ package.json
โโโ README.md
After running the schema.sql, you can use these pre-created accounts:
- Email: [email protected]
- Password: password123
- Email: [email protected]
- Password: password123
- Email: [email protected]
- Password: password123
โโโโโโโโโโโ instructs โโโโโโโโโโโโ
โ users โโโโโโโโโโโโโโโโโโโโโโโโโโโถโ courses โ
โโโโโโฌโโโโโ โโโโโโฌโโโโโโ
โ โ
โ enrolls โ has
โ โ
โผ โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโ
โ enrollments โ โ quizzes โ
โโโโโโโโโโโโโโโโ โโโโโโฌโโโโโ
โ
โ has
โผ
โโโโโโโโโโโโโโโโโโโโ
โ quiz_submissions โ
โโโโโโโโโโโโโโโโโโโโ
- users โ courses: One-to-Many (instructor teaches many courses)
- users โ enrollments: One-to-Many (student enrolls in many courses)
- courses โ enrollments: One-to-Many (course has many students)
- courses โ quizzes: One-to-Many (course has many quizzes)
- quizzes โ quiz_submissions: One-to-Many (quiz has many submissions)
- users โ quiz_submissions: One-to-Many (student submits many quizzes)
- Complete quiz and assignment management UI
- Discussion forum with real-time updates
- File upload for assignments
- Grading interface for instructors
- Student analytics dashboard
- Course search and filtering
- Email notifications
- Real-time chat (Socket.io)
- Mobile responsive design
- Export reports (PDF/Excel)
- Course materials management
- Attendance tracking
This project demonstrates:
-
Database Design
- Normalization (3NF)
- ER modeling
- Choosing between SQL and NoSQL
-
SQL Skills
- Complex JOINs
- Aggregations and subqueries
- Views and stored procedures
- Transactions and ACID properties
-
MongoDB Skills
- Document modeling
- Embedding vs referencing
- Aggregation pipelines
- Indexing strategies
-
Full-Stack Development
- RESTful API design
- JWT authentication
- MVC architecture
- Error handling
-
System Integration
- Polyglot persistence
- Cross-database operations
- Maintaining referential integrity across databases
This project is for educational purposes as part of a DBMS course.
Your Name - DBMS Course Project
- Built as a Database Management Systems course project
- Demonstrates real-world database design principles
- Showcases modern web development practices
Happy Coding! ๐