Question: Set up a new Node.js project. Initialize npm and install necessary dependencies ( express , mysql 2 , express - session, bcrypt , etc .
Set up a new Node.js project.
Initialize npm and install necessary dependencies expressmysqlexpresssession, bcryptetc
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 INTPRIMARY KEY, AUTOINCREMENTusername VARCHARUNIQUE NOT NULLpassword VARCHARNOT NULLrole ENUMadminstaffNOT NULL
studentsTable:
Columns: studentid INTPRIMARY KEY, AUTOINCREMENTfirstname VARCHARNOT NULLlastname VARCHARNOT NULLemail VARCHARUNIQUE NOT NULL
coursesTable:
Columns: courseid INTPRIMARY KEY, AUTOINCREMENTcoursename VARCHARNOT NULLcredits INTNOT NULL
facultyTable:
Columns: facultyid INTPRIMARY KEY, AUTOINCREMENTfirstname VARCHARNOT NULLlastname VARCHARNOT NULLemail VARCHARUNIQUE NOT NULL
enrollmentsTable:
Columns: enrollmentid INTPRIMARY KEY, AUTOINCREMENTstudentid INTFOREIGN KEY REFERENCES studentsstudentidfacultyid INTFOREIGN KEY REFERENCES facultyfacultyidcourseid INTFOREIGN KEY REFERENCES coursescourseid
Database Connection
Implement a connection to the MySQL database using the mysqllibrary
RESTful APIs
Implement RESTful APIs for each entity usersstudents courses, faculty, enrollmentsUse 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
