0% found this document useful (0 votes)
14 views7 pages

DBMS Lab Performance

The document outlines a DBMS lab performance report for a student named Ravi Kumar, detailing the creation of Mentor and StudentS tables, along with their respective data entries. It includes SQL procedures for finding mentors based on average CGPA and identifying students with the highest CGPA per mentor. Additionally, it defines a procedure to find mentors whose mentees all have CGPAs above a specified threshold.

Uploaded by

Technical Heroes
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)
14 views7 pages

DBMS Lab Performance

The document outlines a DBMS lab performance report for a student named Ravi Kumar, detailing the creation of Mentor and StudentS tables, along with their respective data entries. It includes SQL procedures for finding mentors based on average CGPA and identifying students with the highest CGPA per mentor. Additionally, it defines a procedure to find mentors whose mentees all have CGPAs above a specified threshold.

Uploaded by

Technical Heroes
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/ 7

DBMS Lab Performance

Name Ravi Kumar

Roll No. 2330445

Group 1

SET H

Q1: - SOLUTION

CREATE TABLE Mentor (

MentorID INT PRIMARY KEY,

Name VARCHAR(100),

Designation VARCHAR(100)

);

desc Mentor;

CREATE TABLE StudentS (

ID INT PRIMARY KEY,

Name VARCHAR(100),

CGPA DECIMAL(3,2),

MentorID INT,

FOREIGN KEY (MentorID) REFERENCES Mentor(MentorID)

);

desc StudentS;
OUTPUT: -
Q2- SOLUTION: -

INSERT INTO Mentor (MentorID, Name, Designation) VALUES

('1','ISRAJ ALI','Professor'),

('2','GAURAV','Assistant Professor'),

('3','BINITA SAHO','Professor'),

('4','TINA SHARMA','Professor'),

('5','PARAM VERMA','Assistant professor'),

('6','TIRUPATI PRAKASH','Professor'),

('7','SHIKSHA SHARMA','Professor'),

('8','Prateek Tripathi','Assistant Professor'),

('9','jiyan SHARMA','Professor'),

('10','Pinku Sharma','Jn. Professor');

select * from Mentor;

INSERT INTO StudentS (ID, Name, CGPA, MentorID) VALUES

(101, 'Ravi Kumar', 8.9, 1),

(102, 'Koustubh Verma', 7.5, 1),

(103, 'Gargi Saxena', 9.2, 2),

(104, 'Shalini Suman', 7.8, 2),

(105, 'Navnihal Satpute', 9.1, 3),

(106, 'Mehansh Masih', 8.6, 3),

(107, 'Gian Goda', 6.7, 4),

(108, 'Nobita Nobi', 6.9, 4),

(109, 'Shizuka Soni', 5.4, 5),

(110, 'Jack Tison', 7.8, 5);

select * from StudentS;


OUTPUT:
Q3 – SOLUTION: -

DELIMITER //

CREATE PROCEDURE FindMentorsByAvgCGPAs(IN x DECIMAL(3,2))

BEGIN

SELECT m.MentorID, m.Name, AVG(s.CGPA) AS AvgCGPA

FROM Mentor m

JOIN StudentS s ON m.MentorID = s.MentorID

GROUP BY m.MentorID, m.Name

HAVING AvgCGPA > x;

END //

DELIMITER ;

CALL FindMentorsByAvgCGPAs(8.2);

OUTPUT:
Q4 – SOLUTION: -

SELECT s.MentorID, s.ID AS StudentID, s.Name AS StudentName, s.CGPA

FROM StudentS s

WHERE s.CGPA = (SELECT MAX(CGPA) FROM StudentS WHERE MentorID = s.MentorID)

ORDER BY s.MentorID;

OUTPUT:

Q5 – SOLUTION: -

DELIMITER //

CREATE PROCEDURE FindMentorsByAllMenteesCGPAs(IN x DECIMAL(3,2))

BEGIN

SELECT m.MentorID, m.Name

FROM Mentor m

WHERE NOT EXISTS (

SELECT 1 FROM StudentS s

WHERE s.MentorID = m.MentorID AND s.CGPA <= x

);

END //

DELIMITER ;

CALL FindMentorsByAllMenteesCGPAs(7.1);
OUTPUT:

You might also like