Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

DATABASE MANAGEMENT LAB (CS 29006)

School of Electronics Engineering

Experiment Number
3

Name of student
Soham Patra

Roll Number
2230045

Section
ECSC-1

1. Problem Statement:

A) Display all employee names (last name and first name separated by
a comma and a space) and salary with appropriate column aliases.
B) Display all employees who do not get any commission.
C) Display unique building names from LOCATION table.
D) Display all course sections offered in Winter 2003.
E) Display names of faculty members who work in department 1 or 2.
Use IN operator in your query.Find all New York and New Jersey
students.
F) Give a 10% raise to employee number 111.
G) Delete department number 30 from the department table. If it is not
successful, write down your suggestion to make it work.
H) For each course ID, display the maximum count in descending order.
I) Insert a new term in the TERM table.
J) create a custom prompt for user to input any value betwwen 50 and
99 into DeptId column.
K) Find courses with no required prerequisite.
L) Display faculty names in descending order by their department, but in
alphabetical order by their name within each department.
M) Find faculty members whose name start with D.
N) Find students who started in year 2023. Use start term column and
wild card.

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

2. THEORY:
We learned the basics of SQL from the experiment, such as how to
get unique values, filter data with conditions like "WHERE," update
records, sort results, accept errors politely, and choose particular
columns with aliases for clarity.
Advanced techniques such as data inserting, custom prompt
creation, and pattern matching using wildcard characters are
necessary for proficient database management.

3. CODE:

A)

select CONCAT(Fname, ', ', Lname) as 'Employee Name' , Salary


from employee;

Output:

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

B) SELECT EmployeeId, Lname, Fname, Salary

FROM employee

WHERE Commission IS NULL OR Commission = 0;

Output:

C) SELECT DISTINCT Location


FROM dept;

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

OUTPUT:

D) SELECT c.Title, cs.Section, t.TermDesc, f.Name

FROM Crssection cs

INNER JOIN Course c ON cs.CourseId = c.CourseId

INNER JOIN Term t ON cs.TermId = t.TermId

INNER JOIN Faculty f ON cs.FacultyId = f.FacultyId

WHERE t.TermId = 202301;

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

OUTPUT:

E) SELECT Name

FROM Faculty

WHERE DeptId IN (2001, 2002);

SELECT *FROM Student

WHERE State IN ('NY', 'NJ');

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

OUTPUT:

F) UPDATE employee
SET Salary = Salary + (Salary*10/100)

WHERE EmployeeId = 1001;

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

OUTPUT:

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

G) DELETE FROM department WHERE DeptId = 30;

OUTPUT:

H) SELECT CourseId, MAX(MaxCount) AS MaxEnrollment


FROM Crssection

GROUP BY CourseId

ORDER BY MaxEnrollment DESC;

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

OUTPUT:

I) INSERT INTO TERM (TermId, TermDesc, StartDate, EndDate)

VALUES (202403,"Fall","2023-09-10","2023-12-20");

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

OUTPUT:

K) SELECT c.Title, c.CourseId


FROM Course c

LEFT JOIN Course pc ON c.PreReq = pc.CourseId

WHERE pc.CourseId IS NULL;

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

OUTPUT:

L) SELECT d.DeptName, f.Name


FROM Faculty f

INNER JOIN Department d ON f.DeptId = d.DeptId

ORDER BY d.DeptName DESC, f.Name ASC;

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

OUTPUT:

M) SELECT Name

FROM Faculty

WHERE Name LIKE 'D%';

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

Output:

N) SELECT*FROM Student
WHERE StartTerm LIKE '2023%';

Submitted By: Soham Patra


2230045
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

OUTPUT:

Concluding Remarks:
We gained knowledge about how to add data, show a particular column,
sort data by name, date of admission, and perform various other tasks
using SQL queries.

Submitted By: Soham Patra


2230045

You might also like