0% found this document useful (0 votes)
2 views21 pages

DB-Lab Major

The document outlines a database major assignment for creating a Course Management System using MySQL. It includes tasks such as database creation, table design, data insertion, querying, and managing users, along with PL/SQL procedures and triggers. The assignment requires the implementation of various SQL functions and operations to manage student, course, and enrollment data effectively.

Uploaded by

hilalhussain1049
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views21 pages

DB-Lab Major

The document outlines a database major assignment for creating a Course Management System using MySQL. It includes tasks such as database creation, table design, data insertion, querying, and managing users, along with PL/SQL procedures and triggers. The assignment requires the implementation of various SQL functions and operations to manage student, course, and enrollment data effectively.

Uploaded by

hilalhussain1049
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Database major assignment

Name: Ali Noor


ID: 14843
Section: SE (B)
Submitted to Sir: Akbar Ali Shah

Task:
The university needs a Course Management System to store information about students,
courses, enrolments, and instructors. As a database developer, your task is to design, create,
and manipulate a MySQL database to support this system.

1. Database Creation & Table Design (DDL)

• Create a database named University DB.

Tables & Attributes


• Students (StudentID, FirstName, LastName, Email, DOB, Phone)
Table

• Courses (CourseID, CourseName, Credits, Department)

Table
• Instructors (InstructorID, FullName, Email, HireDate, Salary)

Table

• Enrollments (EnrollmentID, StudentID, CourseID, EnrollmentDate, Grade)


Table

2. Data Insertion & Modification (DML)


• Insert at least 5 records in each table.

1 Insertion in student’s table

Table
2 Insertion in Courses table

Table

3 Insertion in Instructors table


Table

4 Insertion in Enrolments table

Table
• Update a student’s phone number using UPDATE.

Table

• Delete an instructor using DELETE.


Table

3. Querying Data using String, Numeric, Aggregate, and Date Functions

• Retrieve students with last names starting with 'A' (using LIKE).
• Convert student names to uppercase (using UPPER()).

• Find the average salary of instructors (using AVG() aggregate function).

• Get the total number of students enrolled in each course (using COUNT()).
• Show enrollment dates in ‘DD-Month-YYYY’ format (using DATE_FORMAT()).

• Calculate the age of students (using TIMESTAMPDIFF(YEAR, DOB,


CURDATE())).
4. Using Operators
• List students who do not have a registered phone number (IS NULL).

• Retrieve courses where Credits > 3 AND Department = 'CS'.

Not : No course have more the 3 credits hours

Find students whose last name is either ‘Khan’ OR ‘Ahmed’


5. Joins & Subqueries
• INNER JOIN: Show students along with the courses they are enrolled in.

• LEFT JOIN: List all students, even those not enrolled in any
course.
• RIGHT JOIN: List all courses and the students who enrolled in them.

• Subquery: Find students who have enrolled in more than one course.

Not: No students have more then one course


6. Views
• Create a view that displays the student’s full name, course name, and
enrollment date.

Views
7: Transaction Management
• Start a transaction.

• Insert a new student record.

• Create a SAVEPOINT.
• Update the student’s email.

• ROLLBACK to the savepoint.

• COMMIT the transaction.


8: Manage Database Users
• Create a new user student_user with a password.

• Grant the user SELECT and INSERT privileges on the Students table.

• Revoke INSERT privilege.


• Delete the user.
9. PL/SQL (Stored Procedures & Functions)
• Create a Stored Procedure

Write a stored procedure that takes a CourseID as input and returns the number of students
enrolled.
• Create a Function

Write a function that calculates student age based on DOB.


10: Create a Trigger
• Create a trigger that automatically updates the Grade column in Enrollments if a student's
score is updated.

You might also like