0% found this document useful (0 votes)
144 views6 pages

4sem CE246 DBMS Practical List 2019-20

This document outlines practical assignments for a Database Management Systems course, including SQL queries to perform on sample databases that cover topics like data definition, data manipulation, aggregation, and more. Students are instructed to write queries to retrieve, insert, update, and manipulate data in databases modeling concepts like a university system, railway routes, banking transactions, and employees. The assignments are meant to help students learn and apply SQL skills as well as database concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
144 views6 pages

4sem CE246 DBMS Practical List 2019-20

This document outlines practical assignments for a Database Management Systems course, including SQL queries to perform on sample databases that cover topics like data definition, data manipulation, aggregation, and more. Students are instructed to write queries to retrieve, insert, update, and manipulate data in databases modeling concepts like a university system, railway routes, banking transactions, and employees. The assignments are meant to help students learn and apply SQL skills as well as database concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

CHAROTAR UNIVERSITY OF SCIENCE & TECHNOLOGY

FACULTY OF TECHNOLOGY & ENGINEERING


U & P U. Patel Department of Computer Engineering

Subject Name:Database Management System Semester:IVth


Subject Code:CE246 Academic Year:Dec-Apr 2020
Practical List
Instructions:
ISO Practical Format: Aim, Software/Hardware Required, Knowledge Required, Theory,
Algorithm/Flow chart, Program, Input and Output, Questions and Answers / Case Study.

Sr.
No. Aim of the practical

1 To study DDL-create and DML-insert commands

Write the following simple SQL Queries on the University Dataset –

1. Find the names of all the students whose total credits are greater than 100
2. Find the course id and grades of all courses taken by any student named 'Tanaka'
3. Find the ID and name of instructors who have taught a course in the Comp. Sci.
department, even if they are themselves not from the Comp. Sci. department. To
test this query, make sure you add appropriate data, and include the corresponding
insert statements along with your query.
4. Find the courses which are offered in both 'Fall' and 'Spring' semester (not
necessarily in the same year).

2 To study DDL-create and DML-insert commands with constraints

Write the following simple SQL Queries on the University Schema Railway Schema -
Bottom Up Approach

1. Find pairs of stations (station codes) that have a track (direct connection) with
distance less than 20Kms between them.
2. Find the IDs of all the trains which have a stop at THANE
3. Find the names of all trains that start at MUMBAI.
4. List all the stations in order of visit by the train 'CST-AMR_LOCAL'.
5. Find the name of the trains which have stop at Thane, before the 6th station in the
route of the train.

Home Assignment – Any Relational schema design – Top Down approach

3 To study various options of like predicate and some Built in Functions


Create table job (job_id, job_title, min_sal, max_sal)
Create table employee (emp_no, emp_name, emp_sal, emp_comm, dept_no)
Create table deposit (a_no,cname,bname,amount,a_date).
Create table borrow (loanno,cname,bname,amount).

Perform following queries

1. Retrieve all data from employee, jobs and deposit.


2. Give details of account no. And deposited rupees of customers having account opened
between dates 01-01-06 and 25-07-06.
3. Display all jobs with minimum salary is greater than 4000.
4. Display name and salary of employee whose department no is 20. Give alias name to
name of employee.
5. Display employee no,name and department details of those employee whose
department lies in(10,20).
6. Display the non-null values of employee’s commission.
7. Display name of customer along with its account no(both column should be displayed
as one) whose amount is not equal to 8000 Rs.
8. Display the content of job details with minimum salary either 2000 or 4000.

To study various options of like predicate


1. Display all employee whose name start with ‘a’ and third character is ‘a’.
2. Display name, number and salary of those employees whose name is 5 characters long
and first three characters are ‘ani’.
3. Display all information of employee whose second character of name is either ‘m’ or
‘n’.
4. Find the list of all customer name whose branch is in ‘andheri’ or ‘dadar’ or ‘virar’.
5. Display the job name whose first three character in job id field is ‘fi_’.
6. Display the title/name of job whose last three character are ‘_mgr’ and there
maximum salary is greater than rs 12000.
7. Display the non-null values of employees and also employee name second character
should be ‘n’ and string should be 5 character long.
8. Display the null values of employee and also employee name’s third character should
be ‘a’.
9. What will be output if you are giving like predicate as ‘%\_%’ escape ‘\’ Select *
from job where job_id like ‘%\_%’ escape ‘\’

4 To perform various data manipulation commands, aggregate functions and sorting


concept on all created tables.
1. List total amount from deposit.
2. List total loan amount from andheri branch
3. Give maximum amount of loan from branch andheri
4. Count total number of customers
5. Count total number of customer’s cities.
6. Create table supplier from employee with all the columns with data..
7. Create table sup1 from employee with first two columns.
8. Create table sup2 from employee with no data
9. Insert the data into sup2 from employee whose second character should be ‘n’ and
string should be 5 characters long in employee name field.
10. Delete all the rows from sup1.
11. Delete the detail of supplier whose sup_no is 103.
12. Rename the table sup2.
13. Destroy table sup1 with all the data.
14. Update the value dept_no to 10 where second character of emp. Name is ‘m’.
15. Update the value of employee name whose employee number is 103.
16. Add one column phone to employee with size of column is 10.
17. Modify the column emp_name to hold maximum of 30 characters.
18. Count the total no as well as distinct rows in dept_no column with a condition of
salary greater than 1000 of employee
19. Display the detail of all employees in ascending order, descending order of their
name and no.
20. Display the dept_no in ascending order and accordingly display emp_comm in
descending order.
21. Update the value of emp_comm to 500 where dept_no is 20.
22. Display the emp_comm in ascending order with null value first and accordingly sort
employee salary in descending order.
23. Display the emp_comm in ascending order with null value last and accordingly sort
emp_no in descending order.

5 To apply the concept of aggregating data using group functions and single raw
functions.

1. List total deposit of customer having account date after 1-jan-96.


2. List total deposit of customers living in city nagpur.
3. List maximum deposit of customers living in bombay.
4. Display the highest, lowest, sum, and average salary of all employees. Label the
columns
5. Maximum, minimum, sum, and average, respectively. Round your results to the
nearest whole number.
6. Write a query that displays the difference between the highest and lowest salaries.
Label the column difference.
7. Create a query that will display the total number of employees and, of that total, the
number of employees hired in 1995, 1996, 1997, and 1998
8. Find the average salaries for each department without displaying the respective
department numbers.
9. Write a query to display the total salary being paid to each job title, within each
department.
10. Find the average salaries > 2000 for each department without displaying the
respective department numbers.
11. Display the job and total salary for each job with a total salary amount exceeding
3000, in which excludes president and sorts the list by the total salary.
12. List the branches having sum of deposit more than 5000 and located in city
bombay.write a query to display the current date. Label the column datefor each
employee, display the employee number, job, salary, and salary increased by 15%
and expressed as a whole number. Label the column new salary
13. Modify your query no 5.(2) to add a column that subtracts the old salary from the
new salary. Label the column increase
14. Write a query that displays the employee’s names with the first letter capitalized
and all other letters lowercase, and the length of the names, for all employees whose
name starts with j, a, or m. Give each column an appropriate label. Sort the results
by the employees’ last names.
15. Write a query that produces the following for each employee:<employee last name>
earns <salary> monthly
16. Display the name, hire date, number of months employed and day of the week on
which the employee has started. Order the results by the day of the week starting
with monday.
17. Display the hiredate of emp in a format that appears as seventh of june 1994
12:00:00 am.
18. Write a query to calculate the annual compensation of all employees (sal+comm.).

6 To Study various Data manipulation methods

1. Give 10% interest to all depositors.


2. Give 10% interest to all depositors having branch vrce
3. Give 10% interest to all depositors living in nagpur and having branch city bombay.
4. Write a query which changes the department number of all employees with empno
7788’s job to employee 7844’current department number.
5. Transfer 10 rs from account of anil to sunil if both are having same branch.
6. Give 100 rs more to all depositors if they are maximum depositors in their respective
branch.
7. Delete depositors of branches having number of customers between 1 to 3.
8. Delete deposit of vijay.
9. Delete borrower of branches having average loan less than 1000.

7 Displaying data from multiple tables – Apply inner , outer, natural join must be use.

8 To study various Data Control Languages (DCL),Transfer Control Language (TCL)


commands

Create a table department1 ( dept _no varchar(3), dept_ name varchar(20),


dept_locationvarchar(50) );
Create a table employee1 ( emp_idvarchar(3) , emp_namevarchar(20) , emp_salary
number(5,2),dep_novarchar(3));
1. Develop a query to grant all privileges of employees table into departments table.
2. Develop a query to grant some privileges of employees table into departments table.
3. Develop a query to revoke all privileges of employees table from departments table.
4. Develop a query to revoke some privileges of employees table from departments table.
5. Write a query to implement the save point.
6. Insert into employees values(‘c03’,’nishit’,50000,’c01’);
7. Select * from employees;
8. Write a query to implement the rollback.
9. Select * from employees;
10. Write a query to implement the commit.
9 To perform basic pl/sql blocks

Write a PL-SQL block for checking weather a given year is a Leap year or not

10 To perform the concept of loop


Find out whether given string is palindrome or not using For, While and Simple
Loop.

11 To understand the concept of “select into” and “% type” attribute.

Create an employees table that is a replica of the emp table. Add a new column, stars, of
varchar2 data type and length of 50 to the employees table for storing asterisk (*).
Create a pl/sql block that rewards an employee by appending an asterisk in the stars column
for every rs1000/- of the employee’s salary. For example, if the employee has a salary amount
of rs8000/-, the string of asterisks should contain eight asterisks. If the employee has a salary
amount of rs12500/-, the string of asterisks should contain 13 asterisks.
Update the stars column for the employee with the string of asterisks.
12 To perform the concept of cursor
1. Display all the information of emp table using %rowtype.
2. Create a pl/sql block that does the following: in a pl/sql block, retrieve the name,
salary, and manager id of the employees working in the particular department. Take
department id from user. If the salary of the employee is less than 1000 and if the
manager id is either 7902 or 7839, display the message <<last_name>> due for a raise.
Otherwise, display the message <<last_name>> not due for a raise.
13 To perform the concept of function and procedure

To update the salary of employee specified by empid. If record exist then update the salary
otherwise display appropriate message. Write a function as well as procedure for updating
salary.
14 To perform the concept of exception handler

Write a PL/SQL block that will accept the employee code, amount and operation. Based on
specified operation amount is added or deducted from salary of said employee. Use user
defined exception handler for handling the exception.
15 To perform the concept of trigger

Write a pl/sql block to update the salary where deptno is 10. Generate trigger that will store
the original record in other table before updation take place
16 To perform the concept of package

1. Create a package specification and package body called EMP_PACK that contains
your NEW_EMP procedure as a public construct, and your VALID_DEPTID function
as a private construct. (You can save the specification and body into separate files.)
2. Invoke the NEW_EMP procedure, using 40 as a department number. Because the
dept_no 40 does not exist in the DEPT table, you should get an error message as
specified in the exception handler of your procedure.
3. Invoke the NEW_EMP procedure, using an existing department ID 80.

You might also like