JSPM UNIVERSITY PUNE
Faculty of Science and Technology
School of Basic and Applied Sciences
MCA/M.Sc. DS&AI/M.Sc. Cyber Security F. Y.
A.Y 2023-24
Name: Dheeraj Basavraj Iti
Roll No: 28
Subject: Advance Database Management System
JSPM UNIVERSITY PUNE
Faculty of Science and Technology
School of Basic and Applied Sciences
CERTIFICATE
This is to certify that Mr.Dheeraj Basavraj Iti bearing roll no.
28 of MCA F. Y. semester 2nd from School of Basic and Applied
Sciences has satisfactorily completed Advance Database
Management System laboratory course code
230GCAM04_02 during the academic year 2023-24.
Course Incharge Program Co-ordinator Dean
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
JSPM UNIVERSITY PUNE
School of Basic and Applied
Sciences
INDEX
Exp. Date of
no. Title of Experiment Execution Sign.
Create a table name student and attribute of s_id, first last and
1.
middle name, address, email, city, and state.
2. Create a table name teacher with an attribute s_id which is a
foreign key and team name?
Create a table name student and with an attributes city which a
3.
default constraints “KOLKATA”?
4. Create a table name student with an attribute s_id which is a
primary key?
5. Insert values into the table student?
6. Update the city of s_id=001 to bby?
7. Create a table name student with an attribute s_id that is not null?
8. Display all the columns of the table name course?
9. Display the columns c_name aliases course name of table name
course?
Display the columns c_fee and c_name using concatenation and
10.
aliases course details of table name course?
Display the course fee and increase in course fee by 3000 where
11.
the course duration is 45_hr?
Remove the duplicate value from course duration with a student ID
12.
from the table name course?
Display the student ID and the first name from the table name
13.
student whose state is westbengal?
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
14. Display all the data of the table course whose course ID is ‘11’.
Display the Lastname and city of the table student where the
15.
student’s first name starts with ‘a’ and consists of 4 characters?
Display the course fee of the table name course which is between 10000 to 50000?
16.
Display the minimum and maximum course fees in the given table?
17.
Display the count number of course names from the table name course?
18.
Display the total course fee in the table name course?
19.
Display the student ID and minimum course fee from the course table and group by
student ID having a course fee less than 102000 and sort the minimum course fee
20.
in descending order?
Display the registration number for the user’s table and the student’s first name on
21. the table student use left join and order by the first name.
Display the registration number for the user’s table and the student’s first name on
22. the table student use inner join?
Display the registration number for the user’s table and the student’s first name and
23. last name from the table student use the right join and order by registration number.
Select all students’ first names and last names and city in the given table using self-
24. join and order by the city?
Select all teachers and all courses in the given table using full join and order by
25. teacher ID
Display the teacher ID and first middle and last name of the teacher where the
26. course name is DBMS?
Display the phone number of the student of who’s registration number is 20?
27.
Display teacher ID first name and phone number whose qualification is b.tech?
28.
Display the first middle and last name of the student where the course fee is
29. minimum?
Display the registration number who live in Jaipur?
30.
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
1. Create a table name student and attribute of s_id, first last and middle name, address, email,
city, and state.
Query:
CREATE TABLE student (
s_id INT PRIMARY KEY AUTO_INCREMENT,
first_name VARCHAR(50),
last_name VARCHAR(50),
middle_name VARCHAR(50),
address VARCHAR(100),
email VARCHAR(100),
city VARCHAR(50),
state VARCHAR(50)
);
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
2. Create a table name teacher with an attribute s_id which is a foreign key and team name?
Query:
CREATE TABLE teacher (
s_id INT,
team_name VARCHAR(50),
FOREIGN KEY (s_id) REFERENCES student(s_id)
);
INSERT INTO teacher (s_id, team_name)
VALUES (1, 'Mathematics');
SELECT * FROM teacher;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
3. Create a table name student and with an attributes city which a default constraints “KOLKATA”?
Query:
CREATE TABLE student (
s_id INT PRIMARY KEY AUTO_INCREMENT,
first_name VARCHAR(50),
last_name VARCHAR(50),
middle_name VARCHAR(50),
address VARCHAR(100),
email VARCHAR(100),
city VARCHAR(50) DEFAULT 'KOLKATA',
state VARCHAR(50)
);
INSERT INTO student (first_name, last_name, middle_name, address, email, state)
VALUES ('John', 'Doe', 'Smith', '123 Main St', '[email protected]', 'NY');
SELECT * FROM student;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
4. Create a table name student with an attribute s_id which is a primary key?
Query:
CREATE TABLE student (
s_id INT PRIMARY
KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
middle_name VARCHAR(50),
address VARCHAR(100),
email VARCHAR(100),
city VARCHAR(50),
state VARCHAR(50)
);
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
5. Insert values into the table student?
Query:
INSERT INTO student (s_id, first_name, last_name, middle_name, address, email, city, state)
VALUES
(1, 'John', 'Doe', 'Smith', '123 Main St', '[email protected]', 'New York', 'NY'),
(2, 'Alice', 'Smith', 'Marie', '456 Elm St', '[email protected]', 'Los Angeles', 'CA'),
(3, 'Michael', 'Johnson', NULL, '789 Oak St', '[email protected]', 'Chicago', 'IL');
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
6. Update the city of s_id=001 to bby?
Query:
UPDATE student
SET city = 'BBY'
WHERE s_id = 1;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
7. Create a table name student with an attribute s_id that is not null?
Query:
CREATE TABLE student (
s_id INT PRIMARY KEY NOT NULL,
first_name VARCHAR(50),
last_name VARCHAR(50),
middle_name VARCHAR(50),
address VARCHAR(100),
email VARCHAR(100),
city VARCHAR(50),
state VARCHAR(50)
);
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
8. Display all the columns of the table name course?
Query:
SHOW COLUMNS FROM course;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
9. Display the columns c_name aliases course name of table name course?
Query:
SELECT course_name AS c_name FROM course;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
10. Display the columns c_fee and c_name using concatenation and aliases course details of
table name course?
Query:
SELECT CONCAT(course_name, ' - Fee: $', course_fee) AS "course details"
FROM course;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
11. Display the course fee and increase in course fee by 3000 where the course duration is 45_hr?
Query:
SELECT course_fee,
CASE
WHEN duration = '45_hr' THEN course_fee + 3000
ELSE course_fee
END AS increased_fee
FROM course;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
12. Remove the duplicate value from course duration with a student ID from the table name course?
Query:
SELECT DISTINCT duration, student_id
FROM course
WHERE student_id = your_student_id;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
13. Display the student ID and the first name from the table name student whose state is westbengal?
Query:
SELECT s_id, first_name
FROM student
WHERE state = 'West Bengal';
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
14. Display all the data of the table course whose course ID is ‘11’.
Query:
SELECT *
FROM course
WHERE course_id = 11;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
15. Display the Lastname and city of the table student where the student’s first name starts with
‘a’ and consists of 4 characters?
Query:
SELECT last_name, city
FROM student
WHERE first_name LIKE 'a ';
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
16. Display the course fee of the table name course which is between 1000 to 1500?
Query:
SELECT course_fee
FROM course
WHERE course_fee BETWEEN 10000 AND 50000;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
17. Display the minimum and maximum course fees in the given table?
Query:
SELECT MIN(course_fee) AS min_course_fee, MAX(course_fee) AS max_course_fee
FROM course;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
18. Display the count number of course names from the table name course?
Query:
SELECT COUNT(DISTINCT course_name) AS course_name_count
FROM course;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
19. Display the total course fee in the table name course?
Query:
SELECT SUM(course_fee) AS total_course_fee
FROM course;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
20. Display the student ID and minimum course fee from the course table and group by student
ID having a course fee less than 102000 and sort the minimum course fee in descending order?
Query:
SELECT student_id, MIN(course_fee) AS min_course_fee
FROM course
WHERE course_fee < 102000
GROUP BY student_id
ORDER BY min_course_fee DESC;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
21. Display the registration number for the user’s table and the student’s first name on the
table student use left join and order by the first name.
Query:
SELECT u.registration_number, s.first_name
FROM users u
LEFT JOIN student s ON u.user_id = s.user_id
ORDER BY s.first_name;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
22. Display the registration number for the user’s table and the student’s first name on the table
student use inner join?
Query:
SELECT u.registration_number, s.first_name
FROM users u
INNER JOIN student s ON u.user_id = s.user_id
ORDER BY s.first_name;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
23. Display the registration number for the user’s table and the student’s first name and last
name from the table student use the right join and order by registration number
Query:
SELECT users.registration_number, students.first_name, students.last_name
FROM users
RIGHT JOIN students ON users.registration_number = students.registration_number
ORDER BY users.registration_number;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
24. Select all students’ first names and last names and city in the given table using self-join and
order by the city?
Query:
SELECT s1.first_name, s1.last_name, s2.city
FROM student s1
JOIN student s2 ON s1.s_id = s2.s_id
ORDER BY s2.city;
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
25. Select all teachers and all courses in the given table using full join and order by teacher ID
Query:
SELECT *
FROM teacher
FULL JOIN course ON teacher.teacher_id = course.teacher_id
ORDER BY COALESCE(teacher.teacher_id, course.teacher_id);
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
26. Display the teacher ID and first middle and last name of the teacher where the course name
is DBMS?
Query:
SELECT t.teacher_id, t.first_name, t.middle_name, t.last_name
FROM teachers t
INNER JOIN courses c ON t.teacher_id = c.teacher_id
WHERE c.course_name = 'DBMS';
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
27. Display the phone number of the student of who’s registration number is 20?
Query:
SELECT phone_number
FROM student
WHERE registration_number = '20';
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
28. Display teacher ID first name and phone number whose qualification is b.tech?
Query:
SELECT teacher_id, first_name,
phone_number FROM teachers
WHERE qualification = 'B.Tech';
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
29. Display the first middle and last name of the student where the course fee is minimum?
Query:
SELECT s.first_name, s.middle_name, s.last_name
FROM student s
JOIN course c ON s.s_id = c.s_id
WHERE c.course_fee = (
SELECT MIN(course_fee)
FROM course
);
Output:
JSPM University Pune
Faculty of Science and Technology
School of Basic and Applied
Sciences
Data Science with Python
30.Display the registration number who live in Jaipur?
Query:
SELECT registration_number
FROM student
WHERE city = 'Jaipur';
Output: