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

DATABASE MANAGEMENT LAB (CS 29006)

School of Electronics Engineering

___________________________________________________________________________________

Experiment Number 3
Experiment Title Data Management and retrival
Date of Experiment 07/02/2024
Date of Submission 07/02/2024

1. Problem Statement:

 Display all employee names (last name and first name separated by a comma
and a space) and salary with appropriate column aliases.
 Display all employees who do not get any commission.
 Display unique building names from LOCATION table.
 Display all course sections offered in Winter 2003.
 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.
 Give a 10% raise to employee number 111.
 Delete department number 30 from the department table. If it is not successful,
write down your suggestion to make it work.
 For each course ID, display the maximum count in descending order.
 Insert a new term in the TERM table.
 Create a custom prompt for user to input any value betwwen 50 and 99 into
DeptId column.
 Find courses with no required prerequisite.
 Display faculty names in descending order by their department, but in
alphabetical order by their name within each department.
 Find faculty members whose name start with C.
 Find students who started in year 2003. Use start term column and wild card.

2. Theory:

 SELECT: Used to retrieve data from one or more tables.


 FROM: Specifies the table from which data is retrieved.
 WHERE: Filters the rows based on a specified condition.
 DISTINCT: Filters duplicate values from the result set.
 GROUP BY: Groups rows that have the same values into summary rows.
 ORDER BY: Sorts the result set by specified columns.
 UPDATE: Modifies existing records in a table.
 SET: Specifies the column(s) to be modified in an UPDATE statement.
 INSERT INTO: Adds new records into a table.
___________________________________________________________________________________
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

___________________________________________________________________________________
 VALUES: Specifies the values to be inserted into the columns.
 IN: Specifies multiple values in a WHERE clause.
 LIKE: Searches for a specified pattern in a column.
 ASC/DESC: Specifies the sorting order (ascending or descending).
 NULL: Represents missing or unknown data.
 IS NULL: Filters rows where the specified column is NULL.
 MAX: Returns the maximum value in a set of values.

3. Code and Result :

select lname,fname,salary from employee;

select lname,fname,salary from employee where commission=0;

___________________________________________________________________________________
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

___________________________________________________________________________________
select distinct building from location;

select * from course where credit =4;

select name from faculty where dept_id in(1,2);

___________________________________________________________________________________
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

___________________________________________________________________________________
select first_name from student where city in("new york","chicago");

update employee set salary=salary+10/100*(salary) where employee_id=1;


Before:-

After:-

___________________________________________________________________________________
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

___________________________________________________________________________________
update department set dept_name=null where dept_id=2 ;

SELECT course_id, MAX(credit) AS max_credit FROM course GROUP BY course_id


ORDER BY max_credit DESC;

insert into term (term_id,term_desc,start_date,end_date) values


(2024,"Spring",'2024-01-05','2024-04-01');

/* Create a custom prompt for user to input any value betwwen 50 and 99 into
DeptId column.*/

___________________________________________________________________________________
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

___________________________________________________________________________________

select * from course where pre_req is null ;

SELECT name FROM faculty ORDER BY dept_id DESC, name ASC;

select name from faculty where name like 'j%';

___________________________________________________________________________________
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

___________________________________________________________________________________
SELECT * FROM student WHERE start_term =2020;

4. Concluding Remarks:

In this experiment we laearnt diferrent methods of data manipulation and


retrival .In conclusion, the provided set of SQL queries demonstrates a diverse
range of operations that can be performed on relational databases. Each query
serves a specific purpose, showcasing the versatility and power of SQL in
managing and manipulating data

___________________________________________________________________________________
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

___________________________________________________________________________________

___________________________________________________________________________________
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030

You might also like