Question: 1 . Project Setup Set up a new Node.js project. Initialize npm and install necessary dependencies ( express , mysql 2 , express - session,
Project Setup
Set up a new Node.js project.
Initialize npm and install necessary dependencies express mysql expresssession, bcrypt etc.
Database Design INCLUDE THE SQL FILE YOU ARE USING TO CREATE THE DATABASE AND THE TABLES!!!!
Create a MySQL database name it CMS with the following tables: users: For staff members. students: For student information. courses: For course details. faculty: For faculty information. enrollments: To store studentcourse and facultycourse associations.
Database Tables Structure
usersTable:
Columns: userid INT PRIMARY KEY, AUTOINCREMENT username VARCHAR UNIQUE, NOT NULL password VARCHAR NOT NULL role ENUMadmin 'staff' NOT NULL
studentsTable:
Columns: studentid INT PRIMARY KEY, AUTOINCREMENT firstname VARCHAR NOT NULL lastname VARCHAR NOT NULL email VARCHAR UNIQUE, NOT NULL
coursesTable:
Columns: courseid INT PRIMARY KEY, AUTOINCREMENT coursename VARCHAR NOT NULL credits INT NOT NULL
facultyTable:
Columns: facultyid INT PRIMARY KEY, AUTOINCREMENT firstname VARCHAR NOT NULL lastname VARCHAR NOT NULL email VARCHAR UNIQUE, NOT NULL
enrollmentsTable:
Columns: enrollmentid INT PRIMARY KEY, AUTOINCREMENT studentid INT FOREIGN KEY REFERENCES studentsstudentid facultyid INT FOREIGN KEY REFERENCES facultyfacultyid courseid INT FOREIGN KEY REFERENCES coursescourseid
Database Connection
Implement a connection to the MySQL database using the mysql library.
RESTful APIs
Implement RESTful APIs for each entity users students, courses, faculty, enrollments Use Express.js for routing. Include CRUD operations for each entity. Utilize MySQL queries for database interactions.
User Authentication
Use bcrypt to hash and verify passwords.
Create a simple loginlogout mechanism using Express sessions.
User Sessions
Implement user sessions for tracking authenticated users.
Create middleware to protect certain routes from unauthorized access.
Views
Implement the following views using a template engine like EJS.
Views for Users:
List Users View: Display a list of all users.
Add User View: Form for adding a new user.
Edit User View: Form for editing user details.
Delete User View: Confirmation for deleting a user.
Views for Students:
List Students View: Display a list of all students.
Add Student View: Form for adding a new student.
Edit Student View: Form for editing student details.
Delete Student View: Confirmation for deleting a student.
Views for Courses:
List Courses View: Display a list of all courses.
Add Course View: Form for adding a new course.
Edit Course View: Form for editing course details.
Delete Course View: Confirmation for deleting a course.
Views for Faculty:
List Faculty View: Display a list of all faculty members.
Add Faculty View: Form for adding a new faculty member.
Edit Faculty View: Form for editing faculty details.
Delete Faculty View: Confirmation for deleting a faculty member.
Views for Enrollments:
List Enrollments View: Display a list of all enrollments.
Enroll Student View: Form for enrolling a student in a course.
Enroll Faculty View: Form for assigning a faculty member to a course.
Withdraw Student View: Confirmation for withdrawing a student from a course.
Remove Faculty View: Confirmation for removing a faculty member from a course.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
