IT260-DBMS Practical List
IT260-DBMS Practical List
Practical-1 Hrs
Aim: Design and implement the schema as per the given information.
Create a schema for the bank that wants to keep the records of different Job 4
profiles along with associated employee and their related information. Bank
also wants to keep the records of their account and loan-related customer
separately in their database.
Constraints –
Not Null Constraints: Critical fields must not be null to ensure data completeness.
Unique Constraints: Certain fields must have unique values to avoid duplicates (e.g.,
Account Number).
Check Constraints: Enforce domain integrity by limiting the values that can be placed in a
column.
Tasks:-
1) Create Table Job (job_id, job_title, min_sal, max_sal)
1
COLUMN NAME DATA TYPE
emp_no Number(3)
emp_name Varchar2(30)
emp_sal Number(8,2)
emp_comm Number(6,1)
dept_no Number(3)
2
a_no cname bname amount a_date
101 Anil andheri 7000 01-jan-06
102 sunil virar 5000 15-jul-06
103 jay villeparle 6500 12-mar-06
104 vijay andheri 8000 17-sep-06
105 keyur dadar 7500 19-nov-06
106 mayur borivali 5500 21-dec-06
Practical-2
Aim: Perform Data Definition Language (DDL) commands and change the 2
existing schema as per the given information.
Constraints –
Not Null Constraints: Ensure critical fields are not null.
Unique Constraints: Ensure data integrity by limiting column values.
Check Constraints: Ensure columns like Account Number have unique values.
Tasks:-
1) Create a table supplier from an employee with all the columns and verify.
Test case: Verify suppler table consists of all columns of employee table.
2) Create table sup1 from an employee with the first two columns and verify.
Test case: Verify sup1 consists of first two columns of employee table.
4) Insert the data into sup2 from employee whose name is ‘Anita’ and verify.
Test case: Verify the details of employee whose name is ‘Anita’ is inserted in sup2 table.
3
5) Rename the table sup2 and verify.
7) Add one column phone to an employee with size of column is Varchar2(10) and verify.
Test case: Verify phone column is added in employee as per the column size.
Test case: Verify the column name of salary is changed to new_sal in sup2 table.
Practical-3
Aim: Perform Data Definition Language (DDL) commands and change the 4
existing schema as per given information.
Constraints –
Not Null Constraints: Ensure critical fields are not null.
Unique Constraints: Ensure data integrity by limiting column values.
Check Constraints: Ensure columns have unique values where required.
Test Cases-
Test Case: Verify all rows are retrieved from each table.
Test Case: Verify the job title and maximum salary for each job.
4
3) Write a query to find out all the branches.
4) Display all the account no. into which rupees are between dates 01-01-06 and 25-07-06.
Test Case: Verify the account numbers with deposits in the specified date range.
Test Case: Verify the names of customers with accounts deposited after the specified date.
6) Display name and salary of employee whose department no is 20. Give alias name to name
of employee.
Test Case: Verify the names and salaries of employees in department 20 with the alias.
7) Display employee no, name and department details of those employee whose department lies
in(10,20).
8) Display employee no, name and department details of those employee whose department not
in(15,30) except 25 .
Test Case: Verify the details of employees excluding departments 15, 30, and 25.
9) Display employee no, name and department details of those employee whose department no
is between 15 and 25.
Test Case: Verify the details of employees in departments between 15 and 25.
10) Display name of all employee whose emp_comm contains the non-null values.
Test Case: Verify the names of employees with non-null emp_comm values.
11) Combine two columns min_sal and max_sal and display it one column using common alias
name.
Test Case: Verify the combined minimum and maximum salary displayed as a single
column.
12) Insert the data into sup2 from employee.
Test Case: Verify the data from Employee is inserted into Supplier2.
5
14) Delete the detail of supplier whose emp_no is 103.
Test Case: Verify the row with emp_no 103 is deleted from Supplier.
15) Update the name of employee to ‘Aman’ name whose emp_name is ‘Anita’.
16) Update the value of employee name whose employee number is 103.
Test Case: Verify the name is updated for the employee with EmployeeID 103.
17) Find out the maximum and minimum salary form job table.
Test Case: Verify the maximum and minimum salary from the JobProfile table.
19) Count the total no as well as distinct rows in dept_no column with a condition of salary
greater than 1000 of employee.
Test Case: Verify the total and distinct count of departments with a salary greater than 1000.
20) Display the detail of all employees in ascending order, descending order of their name and
no.
Test Case: Verify the employee details sorted by name in ascending order and by number in
descending order.
21) Display the dept_no in ascending order and accordingly display emp_comm in descending
order.
Test Case: Verify the dept_no in ascending order and emp_comm in descending order.
23) Display the emp_comm in ascending order with null value first and accordingly sort
employee salary in descending order.
Test Case: Verify emp_comm in ascending order with null values first and salary in
descending order.
24) Display the emp_comm in ascending order with null value last and accordingly sort emp_no
in descending order.
Test Case: Verify emp_comm in ascending order with null values last and emp_no in
descending order.
Practical-4
Aim: - To execute value-matching and pattern-matching conditions on the bank's 2
schema to retrieve specific data based on given requirements.
6
Constraints –
Not Null Constraints: Ensure critical fields are not null.
Unique Constraints: Ensure data integrity by limiting column values.
Check Constraints: Ensure columns have unique values where required.
Tasks:–
1) Display all employees whose name start with ‘A’ and the third character is ‘a’.
2) Display the name, number and salary of those employees whose name is 5 characters long and
the first three characters are ‘Ani’.
3) Display all information of employees whose second character of name is either ‘M’ or ‘N’.
Test case: Verify the details of Aman, Anamika and Anita is displayed.
4) Find the list of all customer names whose branch is in ‘Andheri’ or ‘Dadar’ or ‘Virar’.
Test case: Verify customer names such as Anil, Sunil and keyur is displayed.
5) Display the job name whose first three characters in the job ID field are ‘FI_’.
6) Display the title/name of the job whose last three characters are ‘_MGR’ and whose maximum
salary is greater than Rs 12000.
7) Display the non-null values of employees also employee name's second character should be
‘n’ and the string should be 5 characters long.
8) Display the null values of the employee and also employee name’s third character should be ‘a’.
9) What will be output if you are giving the LIKE predicate as ‘%\_%’ ESCAPE ‘\’
Test Case: Verify that the retrieved job IDs contain an underscore character.
Practical-5
7
Aim: To study data communication using SQL functions, focusing on aggregate, numeric, 4
string, conversion, date, and set operations functions, to manipulate and retrieve data
effectively from the bank's database.
Constraints –
Not Null Constraints: Ensure critical fields are not null.
Unique Constraints: Ensure data integrity by limiting column values.
Check Constraints: Ensure columns have unique values where required.
Test Cases –
Aggregate Functions:
AVG (DISTINCT | ALL | n)
Test Case: Verify the average salary from the JobProfile table and the distinct average salary.
MIN (DISTINCT | ALL | expr)
Test Case: Verify the minimum salary from the JobProfile table.
COUNT (DISTINCT | ALL | expr)
Test Case: Verify the total count of employees and the count of distinct departments.
COUNT (*)
Test Case: Verify the total number of employees.
MAX (DISTINCT | ALL | expr)
Test Case: Verify the maximum salary from the JobProfile table.
SUM (DISTINCT | ALL | n)
Test Case: Verify the total sum of salaries and the distinct total salary.
Numeric Functions:
ABS(n)
Test Case: Verify the absolute difference between salary and 1000.
POWER(m, n)
Test Case: Verify the square of the salary.
ROUND(n, m)
Test Case: Verify the salary rounded to 2 decimal places.
SQRT(n)
Test Case: Verify the square root of the salary.
String Functions:
LOWER(char)
Test Case: Verify the employee first names in lowercase.
INITCAP(char)
Test Case: Verify the employee first names with the initial capital letter.
UPPER(char)
Test Case: Verify the employee first names in uppercase.
SUBSTR(char, m [, n])
Test Case: Verify the first three characters of the employee first names.
LENGTH(word)
Test Case: Verify the length of the employee first names.
LTRIM(char [, set])
Test Case: Verify the employee first names with leading 'A' removed.
RTRIM(char [, set])
8
Test Case: Verify the employee first names with trailing 'a' removed.
LPAD(char1, n [, char2])
Test Case: Verify the employee first names padded to the left with '*' up to a total length of
10.
RPAD(char1, n [, char2])
Test Case: Verify the employee first names padded to the right with '*' up to a total length of
10.
Conversion Functions:
TO_NUMBER(char)
Test Case: Verify the conversion of a string to a number.
TO_CHAR(n [, fmt])
Test Case: Verify the conversion of a number to a formatted string.
Practical-6
Aim: To solve various queries related to grouping and aggregate functions by 2
manipulating data in the product and emp_company tables.
Constraints –
Not Null Constraints: Ensure critical fields are not null.
Unique Constraints: Ensure data integrity by limiting column values.
Check Constraints: Ensure columns have unique values where required.
Test Cases –
9
1) Insert the following values into the product table.
Test Case: Verify that the values are inserted correctly into the product table.
2) Retrieve the product numbers and total quantity ordered for each product from the product
table.
Test Case: Verify that the sum of quantities ordered for each product number is calculated
correctly.
3) Retrieve the product no and the total quantity ordered for product’s ‘P00001’ and
‘P00004’ from product table.
Test Case: Verify that the sum of quantities ordered for product numbers 'P00001' and
'P00004' is calculated correctly.
4) Insert the following values into emp_company
10
6) Find out the average salary of each company.
Test Case: Verify that the average salary for each company is calculated correctly.
7) Find out the names of companies having an average salary of more than 1500.
Test Case: Verify that the companies with an average salary greater than 1500 are listed
correctly.
8) Find out the average salary of each company except ‘ACC’.
Test Case: Verify that the average salary for each company, excluding 'ACC', is calculated
correctly.
Practical-7
2 with
AIM : For a given University schema, create tables and generate a Master-Slave relationship along
all the necessary integrity constraints in MS Access Tool.
Practical-8
AIM - To apply the concept of integrity/data constraints while creating or 4
altering tables in a database for managing sales-related data.
Constraints
Tasks:
Objective: Verify that a valid record can be inserted into the Salespeople table.
Objective: Verify that inserting a record with a duplicate Snum results in an error.
Expected Result: The insertion should fail with a primary key constraint violation error.
11
Test Case 3: Insert a record with a null Sname
Objective: Verify that inserting a record with a null Sname results in an error.
Expected Result: The insertion should fail with a not-null constraint violation error.
Objective: Verify that a record can be inserted with City and Comm as null.
Expected Result: The record should be inserted successfully with City and Comm as null.
Objective: Verify that all records can be retrieved from the table.
Constraints
Tasks:
Test Case 1: Insert a valid record
Objective: Verify that a valid record can be inserted into the Customer table.
Expected Result: The record should be inserted successfully.
12
Objective: Verify that inserting a record with a null Cname results in an error.
Expected Result: The insertion should fail with a not null constraint violation error.
3) Create table Order where Order_no number(4) P.K, Amount number(5), Odate
varchar2(10), Cnum number(4) F.K, (where cnum refer customer table). Snum
number(4) F.K (where snum refers salespeople table).
Constraints
Tasks:
Test Case 1: Insert a valid record
Objective: Verify that a valid record can be inserted into the Orders table.
Expected Result: The record should be inserted successfully.
13
Expected Result: The insertion should fail with a foreign key constraint violation error for Snum.
4. Table: Sales_order
Constraints
Test Case: Verify that all constraints, including the primary key, foreign key, check constraints, and
default values, are correctly applied.
14
5. Table: salesman_master
Constraints
6. Table: Client_master
Constraints
15
Address Varchar2(30)
City Varchar2(15)
Pincode Number(8)
State Varchar2(15)
Bal_due Number(10,2)
Test Case: Verify that all constraints, including the primary key, not null, and check constraints, are
correctly applied.
Practical-9
Aim: To study and execute various JOIN commands to perform data retrieval and 2
manipulation from Salespeople, Customer, and Order tables based on
specific requirements.
Constraints
Salespeople:
------------------------------------------------------------------------------
Customer:
-----------------------------------------------------------------------------------------------------
16
2003 Liu San Jose 300 1002
Order:
Test Cases -
2. All orders except those with 0 or null value in the amt field
3. Largest order taken by each sales order value of more than 3000
Expected Result: Largest order amount for each salesperson where the order value is more than
3000.
4. All combinations of salespeople and customers who belong to the same city
17
Expected Result: List of salespeople and customers who are from the same city.
5. List each order with the name of the customer who placed the order
Expected Result: List of orders with the corresponding customer names who placed the orders.
Expected Result: List of customers serviced by salespeople with a commission greater than
12%.
7. Produce names and cities of all customers with the same rating as Hoffman
Expected Result: List of customers who have the same rating as Hoffman.
Expected Result: Number of customers with a rating above the average rating of customers
from San Jose.
9. Find the total amount in orders for each salesperson for whom this total is greater than
the amount of the largest order in the order table
Expected Result: Total amount of orders for each salesperson where the total is greater than the
largest single order amount in the orders table.
10. Create a union of two queries that shows all customers' names, cities, and ratings.
Those with a rating of 200 or greater will have the words ‘High Rating’ while others will
have ‘Low Rating’.
Expected Result: List of customers with their names, cities, ratings, and a rating category
indicating 'High Rating' or 'Low Rating'.
Practical-10
Aim: To create a PL/SQL procedure that performs the multiplication of two 2
numbers. The procedure will take two input parameters and return the
product.
Constraints
1. Input Parameters: The procedure will accept two input parameters of type NUMBER.
2. Output Parameter: The procedure will have an output parameter to return the result of the
multiplication.
3. Error Handling: The procedure will handle potential errors such as invalid input types.
Tasks -
Test Case 1: Multiplying two positive numbers
18
Input: num1 = 10, num2 = 5
Constraints
1. Deletion Condition: Delete records from the main table where the age is 21.
2. Trigger: Before deleting a record, store the original record in another table.
Tasks -
Expected Result: Records with an age of 21 ('Alice' and 'Charlie') should be deleted.
19
Objective: Verify that the trigger successfully stores original records in the DeletedRecords
table before deletion.
Expected Result: The DeletedRecords table should contain the original records of 'Alice' and
'Charlie' before they were deleted.
20