MCA 207: DBMS Lab
Lectures: 6 Periods/Week | Sessional Marks: 30 |
University Exam: 3 Hours | University Examination Marks: 70 |
Lab cycle
Cycle I:-
Aim:Marketing Company wishes to computerize their operations by using
following tables.
Table Name: Client_MasterDescription:This table stores the information about the clients.
Column Name | Data Type | Size | Attribute |
Client_no | Varchar2 | 6 | Primary Key and first letter should starts with 'C' |
Name | Varchar2 | 10 | Not null |
Address1 | Varchar2 | 10 | |
Address2 | Varchar2 | 10 | |
City | Varchar2 | 10 | |
State | Varchar2 | 10 | |
Pincode | Number | 6 | Not null |
Bal_due | Number | 10,2 |
Table Name:Product_master
Description:This table stores the information about products.
Column Name | Data Type | Size | Attribute |
Product_no | Varchar2 | 6 | Primary Key and first letter should starts with 'P' |
Description | Varchar2 | 10 | Not null |
Profit_percent | Number | 2,2 | Not null |
Unit_measure | Varchar2 | 10 | |
Qty_on_hand | Number | 8 | |
Record_lvl | Number | 8 | |
Sell_price | Number | 8,2 | Not null, can't be 0 |
Cost_price | Number | 8,2 | Not null, can't be 0 |
Table Name:salesman_master
Description:This table stores the salesmen working in the company
Column Name | Data Type | Size | Attribute |
Salesman_id | Varchar2 | 6 | Primary Key and first letter should starts with 'S' |
Name | Varchar2 | 10 | Not null |
Address1 | Varchar2 | 10 | |
Address2 | Varchar2 | 10 | |
City | Varchar2 | 10 | |
State | Varchar2 | 10 | |
Pincode | Number | 6 | Not null |
Sal_amt | Number | 8,2 | Should not null and zero |
Target_amt | Number | 6,2 | Should not null and zero |
Remarks | Varchar2 | 10 |
Table Name:sales_order
Description:This table stores the information about orders
Column Name | Data Type | Size | Attribute |
S_order_no | Varchar2 | 6 | Primary Key and fisrt char is 'O' |
S_order_date | Date | ||
Client_no | Varchar2 | 6 | Foreign key |
Delve_address | Varchar2 | 20 | |
Salesman_no | Varchar2 | 6 | Foreign key |
Delve_type | Varchar2 | 1 | Delivery: part(P)/Full(F) and default 'F' |
Billed_yn | Char | 1 | |
Delve_date | Date | Can't be less than the s_order_date | |
Order_status | Varchar2 | 10 | Values in 'IN PROCESS', FULFILLED', 'BACK ORDER, 'CANCELLED' |
Remarks | Varchar2 | 10 |
Table Name:sales_order_details
Description:This table stores the information about products ordered
Column Name | Data Type | Size | Attribute |
S_order_no | Varchar2 | 6 | Primary key, foreign key references sales_order table |
Product_no | Varchar2 | 6 | Primary key, foreign key references product_master table |
Qty_ordered | Number | 8 | |
Qty_disp | Number | 8 | |
Product_rate | Number | 10,2 |
Table Name:challan_master
Description:This table stores the information about challansmade for orders.
Column Name | Data Type | Size | Attribute |
Challan_no | Varchar2 | 6 | Primary key, first two letters must start with 'CH' |
S_order_no | Varchar2 | 6 | Foreign key references sales_order |
Challan_date | Date | ||
Billed_yn | Char | 1 | Values in 'Y', 'N' default 'N' |
Table Name:Challan_Details
Description:This table stores the information about challan details.
Column Name | Data Type | Size | Attribute |
Challan_no | Varchar2 | 6 | Primary key, foreign key references challan_master table |
Product_no | Varchar2 | 6 | Primary key, foreign key references product_master table |
Qty_disp | Number | 4,2 | Not null |
Solve the following queries by using above tables
- Retrieve the list of names and cities of all the clients.
- List the various products available from product_master.
- Find out the clients who stay in a city whose second letter is 'a'.
- Find the list of all clients who stay in the city 'CHENNAI' or 'DELHI'.
- List all the clients located at 'CHENNAI'.
- Print the information from sales order as the order the places in the month of January.
- Find the products with description as 'Floppy Drive' and 'Pen drive'.
- Find the products whose selling price is greater than 2000 and less than or equal to 5000.
- Find the products whose selling price is more than 1500 and also find the new selling price as original selling price *15.
- Find the products in the sorted order of their description.
- Divide the cost of product '540 HDD' by difference between its price and 100.
- List the product number, description, sell price of products whose description begin with letter 'M'.
- List all the orders that were cancelled in the month of March.
- Count the total number of orders.
- Calculate the average price of all the products.
- Determine the maximum and minimum product prices.
- Count the number of products having price grater than or equal to 1500.
- Find all the products whose quantity on hand is less than reorder level.
- Find out the challan details whose quantity dispatch is high.
- Find out the order status of the sales order, whose order delivery is maximum in the month of March.
- Find out the total salesmade by the each salesman.
- Find the total revenue gained by the each product sales in the period of Q1 and Q2 of year 2006.
- Print the description and total qty sold for each product..
- Find the value of each product sold.
- Calculate the average qty sold for each client that has a maximum order value of 1,50,000.
- List the products which has highest sales.
- Find out the products and their quantities that will have to deliver in the current month.
- Find the product number and descriptions of moving products.
- Find the names of clients who have purchased 'CD DRIVE'.
- List the product numbers and sales order numbers of customers having quantity ordered less than 5 fromthe order details for the product '1.44 Floppies'.
- Find the product numbers and descriptions of non-moving products.
- Find the customer names and address for the clients, who placed the order '019001'.
- Find the client names who have placed orders before the month of May, 2006.
- Find the names of clients who have placed orders worth of 10000 or more.
- Find out if the product is '1.44 drive' is ordered by any client and print the client number, name to whom it is sold.
Cycle II:-Aim: A Manufacturing Company deals with various parts and various suppliers supply these parts. It consists of three tables to record its entire information. Those are as follows
S(SNO,SNAME,CITY,STATUS)
P(PNO,PNAME,COLOR,WEIGTH,CITY,COST)
SP(SNO,PNO,QTY)
J(JNO,JNAME,CITY)
SPJ(SNO,PNO,JNO,QTY)
- Get Suppliers Names for Suppliers who supply at least one red part.
- Get Suppliers Names for Suppliers who do not supply part 'P2'
- Using Group by with Having Clause, Get the part numbers for all the parts supplied by more than one supplier.
- Get supplier numbers for suppliers with status value less the current max status value.
- Get the total quantity of the part 'P2' supplied.
- Get the part color, supplied by the supplier 'S1'
- Get the names of the parts supplied by the supplier 'Smith' and "Black"
- Get the Project numbers, whose parts are not in Red Color, from London.
- Get the suppliers located from the same city.
- Get the suppliers, who does not supply any part.
- Find the pnames of parts supplied by London Supplier and by no one else.
- Find the sno's of suppliers who charge more for some part than the average cost of that part.
- Find the sid's of suppliers who supply only red parts.
- Find the sid's of suppliers who supply a red and a green part.
- Find the sid's of suppliers who supply a red or green part.
An Airline System would like to keep track their information by using the following relations.
Flights (flno: integer, from: string, to: string, distance: integer, Price: integer)
Aircraft (aid: integer, aname: string, cruising_range: integer)
Certified (eid: integer, aid: integer)
Employees (eid: integer, ename: string, salary: real)
Note that the employees relation describes pilots and other kinds of employees as well; every pilot is certified for aircraft and only pilots are certified to fly. Resolve the following queries:
- For each pilot who is certified formore than three aircraft, find the eid's and the maximum cruising range of the aircraft that he (or She) certified for.
- Find the names of pilots whose salary is less than the price of the cheapest route from Los Angeles to Honolulu.
- Find the name of the pilots certified fromsome Boeing aircraft.
- For all aircraft with cruising range over 1,000 miles, find the name of the aircraft and the average salary of all pilots certified for this aircraft.
- Find the aid's of all aircraft than can be used from Los Angels to Chicago.
- Print the enames of pilots who can operate planes with cruising range greater than 3,000 miles, but are not certified by Boeing aircraft.
- Find the total amount paid to employees as salaries.
- Find the eid's of employees who are certified for exactly three aircrafts.
- Find the eid's of employee who make second highest salary.
- Find the aid's of all than can be used on non-stop flights from Bonn to Chennai.
Aim:An enterprise wishes to maintain a database to automate its operations. Enterprise divided into to certain departments and each department consists of employees. The following two tables describes the automation schemas
DEPT (DEPTNO, DNAME, LOC)
EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO)
- Create a view, which contain employee names and their manager names working in sales department.
- Determine the names of employee, who earn more than there managers.
- Determine the names of employees, who take highest salary in their departments.
- Determine the employees, who located at the same place.
- Determine the employees, whose total salary is like the minimum salary of any department.
- Update the employee salary by 25%, whose experience is greater than 10 years.
- Delete the employees, who completed 32 years of service.
- Determine the minimumsalary of an employee and his details, who join on the same date.
- Determine the count of employees, who are taking commission and not taking commission.
- Determine the department does not contain any employees.
- Find out the details of top 5 earners of company. (Note: Employee Salaries should not be duplicate like 5k,4k,4k,3k,2k)
- Display thosemanagers name whose salary is more than an average salary of his employees.
- Display the names of the managers who is having maximum number of employees working under him?
- In which year didmost people join the company? Display the year and number of employees.
- Display ename, dname even if there no employees working in a particular department(use outer join).
- WRITE A PL/SQL PROGRAM TO CHECK THE GIVEN NUMBER IS STRONG OR NOT.
- WRITE A PL/SQL PROGRAM TO CHECK THE GIVEN STRING IS PALINDROME OR NOT.
- WRITE A PL/SQL PROGRAM TO SWAP TWO NUMBERS WITHOUT USING THIRD VARIABLE.
- WRITE A PL/SQL PROGRAM TO GENERATE MULTIPLICATION TABLES FOR 2, 4, 6
- WRITE A PL/SQL PROGRAM TO DISPLAY SUM OF EVEN NUMBERS AND SUM OF ODD NUMBERS IN THE GIVEN RANGE.
- WRITE A PL/SQL PROGRAM TO CHECK THE GIVEN NUMBER IS PALLINDROME OR NOT.
- THE HRD MANAGER HAS DECIDED TO RAISE THE EMPLOYEE SALARY BY 15%. WRITE A PL/SQL BLOCK TO ACCEPT THE EMPLOYEE NUMBER AND UPDATE THE SALARY OF THAT EMPLOYEE. DISPLAY APPROPRIATE MESSAGE BASED ON THE EXISTENCE OF THE RECORD IN EMP TABLE.
- WRITE A PL/SQL PROGRAM TO DISPLAY TOP 10 ROWS IN EMP TABLE BASED ON THEIR JOB AND SALARY.
- WRITE A PL/SQL PROGRAM TO RAISE THE EMPLOYEE SALARY BY 10%, FOR DEPARTMENT NUMBER 30 PEOPLE AND ALSO MAINTAIN THE RAISED DETAILS IN THE RAISE TABLE.
- WRITE A PROCEDURE TO UPDATE THE SALARY OF EMPLOYEE, WHO ARE NOT GETTING COMMISSION BY 10%.
- WRITE A PL/SQL PROCEDURE TO PREPARE AN ELECTRICITY BILL BY USING
FOLLOWING TABLE TABLE USED: ELECT
NAME NULL? TYPE
MNO NOT NULL NUMBER(3) CNAME VARCHAR2(20) CUR_READ NUMBER(5) PREV_READ NUMBER(5) NO_UNITS NUMBER(5) AMOUNT NUMBER(8,2) SER_TAX NUMBER(8,2) NET_AMT NUMBER(9,2)
-
WRITE A PL/SQL PROCEDURE TO PREPARE AN TELEPHONE BILL BY USING
FOLLOWING TABLE. AND PRINT THE MOTHLY BILLS FOR EACH CUSTOMER
TABLE USED : PHONE.
NAME NULL? TYPE ---------------- -------- --------
TEL_NO NOT NULL NUMBER(6) CITY VARCHAR2(10) PR_READ NUMBER(5) CUR_READ NUMBER(5) NET_UNITS NUMBER(5) TOT_AMT NUMBER(8,2)
- WRITE A PL/SQL PROGRAM TO RAISE THE EMPLOYEE SALARY BY 10%, WHO ARE COMPLETED THERE 25 YEARS OF SERVICE AND STORE THE DETAILS AT PPROPRIATE TABLES (DEFINE THE RETAIR_EMP TABLE).
- WRITE A PL/SQL PROCEDURE TO EVALUATE THE GRADE OF A STUDENT
WITH FOLLOWING CONDITIONS:
FOR PASS: ALL MARKS > 40
FOR I CLASS: TOTAL%>59
FOR II CLASS: TOTAL%BETWEEN >40 AND <60
FOR III CLASS: TOTAL%=40
AND ALSOMAINTAIN THE DETAILS IN ABSTRACT TABLE.
TABLES USED
1. TABLE STD
NAME NULL? TYPE ---------------- -------- --------
NO NOT NULL NUMBER NAME VARCHAR2(10) INTNO NUMBER CLASS NOT NULL VARCHAR2(10) M1 NUMBER M2 NUMBER M3 NUMBER M4 NUMBER M5 NUMBER
2. TABLE ABSTRACT
NAME NULL? TYPE ---------------- -------- --------
STDNO NUMBER STDNAME VARCHAR2(10) CLASS VARCHAR2(10) MONTH VARCHAR2(10) INTNO (INTERNAL NUMBER) NUMBER TOT NUMBER GRADE VARCHAR2(10) PERCENT NUMBER DAT_ENTER DATE
- CREATE AN VARRAY, WHICH HOLDS THE EMPLOYEE PHONE NUMBERS (AT LEAST THREE NUMBERS).
- CREATE AN OBJECT TO DESCRIBE THE DETAILS OF ADDRESS TYPE DATA.
- WRITE A PL/SQL PROCEDURE TO READ THE DATA INTO THE TABLE AS PER
THE FOLLOWING DESCRIPTION.
AttributeName Data Type DETAILS EMPLOYEE NUMBER NUMBER EMPLOYEE NAME CHARACTER ADDRESS OBJECT STREET NUMBER STREET NAME TOWN DIST AND STATE QUALIFICATION CHARACTER PHONE NUMBER OBJECTVARRAY HOLDS THREE PHONE NUMBER