Babu Madhav Institute Of Information Technology 2016...

13
Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti Bhatt, Ms.Hinal Shah Page 1 Practical No: 1 Enrolment No: Practical Problem Create the following tables: Doctor(dno,dname,qualification,d_add),Patient(pno,pname,dob,p_add,gender), Treatment(tno,tdetail), Charges(dno,tno,charges) Appointment(ano,dno,pno,tno,a_date,status) 1) Display the appointment information of Dr. Shukla. 2) Display information of all doctors who are presently treating at least 10 patients. 3) Display details of all doctors who are charging less than Rs. 150 for any type of treatment. 4) Display details of all doctors whose charges are highest for each different treatment type. 5) Display detailed list of appointment for Dr. Pal in the month of June. 6) Display information of all senior citizens who are being treated by Dr. Vyas. 7) Display information of all female patients who are getting treatment from Dr.shukla. 8) Display information of patients who have visited the same dentist more than 3 times. 9) Delete all those information whose appointment was cancel. 10) Create a table t_patient having the same structure as that of patient but data of only teenagers. 11) Display all dentists who are presently treating at least 10 patients. 12) Display information of patients who are getting more than two type of treatment. 13) List patient’s details who had taken appointment of tomorrow. 14) Receptionist wants to know total number of collection of today. 15) Display minimum, maximum and average charges for treatment. Objective(s) To understand the concept of DBMS query. Pre-requisite To know basic DBMS commands CREATE,SELECT,UPDATE and DELETE Duration 1 hour PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems. PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development. CO(s) to be achieved CO1: Differentiate DBMS & RDBMS and use SQL data types. Solution contain Query statements with output Nature of submission Handwritten References for solving the problem Beginning DB2: From Novice to Professional, Allen G. http://w3schools.com/Sql/ Post Laboratory questions Post Laboratory questions: 1. Give differences between CHAR and VARCHAR datatype. 2. What is use of DELETE statement? 3. What it a difference between floor () and ceil ()? Describe using example. 4. What is a use of INSTR ()? 5. What is a difference between highest and max? Using example. Assessment Desired objective(s) satisfied? [Yes/No/Partial] Verified By Use of Join Query Aggregate function Knowledge Query with output

Transcript of Babu Madhav Institute Of Information Technology 2016...

Page 1: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 1

Practical No: 1 Enrolment No:

Practical Problem Create the following tables:

Doctor(dno,dname,qualification,d_add),Patient(pno,pname,dob,p_add,gender), Treatment(tno,tdetail), Charges(dno,tno,charges) Appointment(ano,dno,pno,tno,a_date,status) 1) Display the appointment information of Dr. Shukla. 2) Display information of all doctors who are presently treating at least 10 patients. 3) Display details of all doctors who are charging less than Rs. 150 for any type of treatment. 4) Display details of all doctors whose charges are highest for each different treatment type. 5) Display detailed list of appointment for Dr. Pal in the month of June. 6) Display information of all senior citizens who are being treated by Dr. Vyas. 7) Display information of all female patients who are getting treatment from Dr.shukla. 8) Display information of patients who have visited the same dentist more than 3 times. 9) Delete all those information whose appointment was cancel. 10) Create a table t_patient having the same structure as that of patient but data of only teenagers. 11) Display all dentists who are presently treating at least 10 patients. 12) Display information of patients who are getting more than two type of treatment. 13) List patient’s details who had taken appointment of tomorrow. 14) Receptionist wants to know total number of collection of today. 15) Display minimum, maximum and average charges for treatment.

Objective(s) To understand the concept of DBMS query.

Pre-requisite To know basic DBMS commands CREATE,SELECT,UPDATE and DELETE

Duration 1 hour

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO1: Differentiate DBMS & RDBMS and use SQL data types.

Solution contain Query statements with output

Nature of submission Handwritten

References for solving

the problem

Beginning DB2: From Novice to Professional, Allen G.

http://w3schools.com/Sql/

Post Laboratory

questions

Post Laboratory questions: 1. Give differences between CHAR and VARCHAR datatype. 2. What is use of DELETE statement? 3. What it a difference between floor () and ceil ()? Describe using example. 4. What is a use of INSTR ()?

5. What is a difference between highest and max? Using example.

Assessment

Desired objective(s) satisfied? [Yes/No/Partial]

Verified By

Use of Join Query

Aggregate function Knowledge

Query with output

Page 2: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 2

Practical No: 2 Enrolment No:

Practical Problem Consider above table and perform following task and generate report as per instruction 1)Display the report of patient as following format ---------------------- Doctor Detail ------------------- Mr. Shah : MD Mr.vyas : D.H.M.S 2) Display patient name in reverse order. -------------------------------------------- Patient name Reverse name -------------------------------------------- ZILU ULIZ NIL LIN 3) Repeat the patient name twice. -------------------------------------------- Patient name Name -------------------------------------------- ZILU ZILUZILU NIL NILNIL 4) Display charges in proper format (Using specified delimiter) ---------------------------- Charges -------------------------- 10,000 1,000 500 5) Retrieve date, year, month, hour, minute and second of DOB of patient appointment date.(Also perform with current time)

Date Month Year Hour Minute Second

19 04 1994 10 19 20

6) Right pad and left pad patient name with asterix (*) to the length 10. ---------------------------------- ZILU****** ******ZILU ---------------------------------- 7) Rajesh wants to know last day of current month. Help him.

Objective(s) To understand the concept of DBMS query and functions used in SQL statement for

retrieve data easily.

Pre-requisite To know basic DBMS commands CREATE,SELECT,UPDATE and DELETE

Duration 1 hour

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

Page 3: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 3

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO1: Differentiate DBMS & RDBMS and use SQL data types.

Solution must contain Query statements with output

Nature of submission Handwritten

References for solving

the problem

http://w3schools.com/Sql/

Post Laboratory

questions

Post Laboratory questions 1. Specify range of integer and unsigned integer. 2. List the doctor whose name having initial character as ‘A’. 3. What is the difference between DELETE and DROP commands? 4. In the WHERE clause what is the use of BETWEEN and IN?

Assessment

Desired objective(s) satisfied? [Yes/No/Partial]

Verified By

Use of Inbuilt Function

DML statement Knowledge

Page 4: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 4

Practical No: 3 Enrolment No:

Practical Problem Studentmaster (enrollmentno,name, gender,smsnumber,email, contNo,admissiondate,address,city,DOB) Subjectmaster(subjectcode,subjectname,credits ,typesofsubject(PR/Th)) Semesermaster(semid,subjectcode) Marksmaster(id,enrollmentno,semid,subjectcode,typesofexam,frommarks,securedmarks,division). Insert at list 10 record in each table. 1. Mitsu wants to identify number of subject in 7th semester along with its details. 2. Count the students who are coming from surat. 3. Check FOP quiz evaluation entry is completely done or not. 4. Prepare report of student who is fail in dbms exam.(should contain enrolment number,name,marks,passingmarks,subjectcode,semester,typesofsubject) 5. Search for a students whose name sounds like “Deep”. 6. List the students list who had not given SMS number. 7. Counsellor wants to know student list who having birthday in this month. 8. Head of department wants to maximum marks in FOP quiz. 9. Subject teacher wants to know student who had secured lowest marks in unit test. 10. Head of the department want to average marks of student in CFO subject. 11. CELI and FLOOR the entire FOP subject marks. 12. Remove student details whose enrolment number is 79 and 48. 13. Count total marks of 071 and 081 in Fop (Calculate all the exam). 14. Display division wise marks report of maths. 15.Modify subject credit 04 of RDBMS subject of 2nd semester(Without using update keyword)

Objective(s) To understand the concept of DBMS query and functions used in SQL statement for

retrieve data easily.

Pre-requisite To know basic DBMS commands CREATE,SELECT,UPDATE and DELETE

Duration 1 hour

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO1: Differentiate DBMS & RDBMS and use SQL data types.

Solution must contain Query with output

Nature of submission Handwritten

References http://w3schools.com/Sql/

Post Laboratory

questions

1. What is the use of Alter keyword? 2. How to display report of student as per day? 3. How to display students name whose name start from ‘H’? 4. How to display student’s name thathave last character is ‘L’.

Assessment

Desired objective(s) satisfied? [Yes/No/Partial]

Verified By

Use of Join Query

Aggregate function Knowledge

Query with output

Page 5: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 5

Practical No: 4 Enrolment No:

Practical Problem 1. Mitsu shah studying in BMIIT, 2nd semester. Her counselor wants to check total

numbers of leave applied by Mitsu and total number of granted leave of that student. Write a procedure to implement above functionality and display information in a proper format. Consider table: Student(Sid,Sname,Class,Sem, gender, city),Leave master( Lid, LeaveType, Stud_id, Reason, Status)

2. Counselor of 2nd semester wants to identify number of boys, number of girls

under her counseling and number of students coming from “Valsad” city. Write a procedure to implement above functionality and display result in proper format. Consider table of above question: 2.

3. In company, worker efficiency is determined on the basis of required to complete a

particular job. If time taken by the worker is between 2-4 hours, then the worker is said to be high efficient. If the time required by the worker is between 4-6 hours, then the worker is ordered to improve efficiency. If time is between 6-8 hours, the worker is given training to improve his efficiency, and if the time taken by the worker is more than 8 hours, then the worker is not eligible for company. Write a procedure to take time that is taken by worker to complete a job from keyboard and display the appropriate category of worker on the screen.

consider table: Employee(eid,ename,department,designation,worker effiecncy,status) 4. Mr. John having employee id emp050 working as a Developer in a Lemon

Technology. John wants to know how much increment he will get in this Year. Help Mr. John to find his updated salary using procedure.

Company Criteria for Increment as follows.. Give increment of 3000 Rs if experience more than 3 Year. Give increment of 2000 Rs if experience more than 1Year. Give increment of 5000 Rs, if experience more than 5 Year No increment if experience less than 1Year..

Consider table: Employee (Id, Name, Salary, Dept, Designation, No_of_Experience) 5. “ZINK Corporation “is giving bonus in diwali to Mr. Varma having employee id

E202 . as per designation of employee. Bonus will be directly added in salary account. If employee is tester then give raise of 12%, if developer then gives raise of 10%, if manager, raise salary by 15%, for other department gives raise of 5%.

[Must use concept of Switch case] Consider table employeemaster(eno,ename,designation,salary, joing_date) 6. Domestic consumer can calculate the bill using the different charges for different

unit given in the below table Mr. Akash Bhadra wants to pay the electricity bill, help him to find how much payment he has to pay, and after payment the details should be maintain in BillData.

[Must use concept of Switch case] Criteria which are to be considered while calculation of bill:

UNIT CHARGES 0-100 200 fixed.

Page 6: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 6

100-200 200+ Extra unit*3. 200-300 200+Extra unit*4. 300-400 200+Extra unit*5. Consider Table: Customer (Cust_id,Cust_Name,Unit_Consumed,Total_Bill_Amt)

BillData(bid,cust_id,TotalBillAmt,DateofPayment) [Note: Direct insertion in BillData is not allowed, Use Procedure for calculation]

Objective(s) To understand the concept of Control statement.

Pre-requisite Students able to understand the working and use of IF statement and procedure.

Duration 3hour

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO2: Use of IF, CASE, FOR, LOOP, WHILE and REPEAT control flow statements.

Solution must contain SQL /PL block with output

Nature of submission Handwritten

References http://w3schools.com/Sql/

Post Laboratory

questions

Post Laboratory questions: 1. What is use of if statement? 2. How to terminate if statement? 3. Define case statement. 4. What is the use of while loop?

Assessment

Desired objective(s) satisfied? [Yes/No/Partial]

Verified By

Use of IF statement

Use of Case statement

Logic clarity

Page 7: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 7

Practical No: 5 Enrolment No:

Practical Problem 1. Online resume builder is a system which provides a facility to build professional resume online. To use this system, user registration first and then after credential user can build a resume. Provide functionalityof registration and login using procedure.Consider Table: Customermaster(cid, cname, contactNo, DOB, emailId, password) Write a procedure which takes all details of customer as a parameter and

register the user. Note: cno must be generated automatically. Write a procedure which takes emailed and password as a parameter and

check the validity of user by proper message. 2. BMIIT wants to add one more facility in Student Information System, by which

Programme Coordinator can check present or absent students according to subject wise. Help BMIIT in developing this facility. System enters the details in following table.

Lecture(Semseter,SubjectName,EnrollmentNo,StudentsName,Status{Present/Absent}) Write a procedure which takes subject name as a parameter and

generate absent report for subject Write a procedure which takes semester, student number as a

parameter and display attendance of student. Write a procedure which takes subject name and student as a

parameter and display student attendance based on selected subject.

3. HDFC bank is having online application by which customers can do the operation like money transfer, deposit amount, check past transaction, etc. But nowadays customers are not able to view their past transaction, provide solution by creating procedure which takes account no as a parameter. Consider Table : Customer(accountno,name,address,dob,gender) Transaction(accountno,date,type{withdraw/deposite},amount,totalamount) Write a procedure which takes account no and types as a parameter and display

all the transaction of that type. Write a procedure which takes account no and to date, and from date as a

parameter and display all the transaction between given date. 4. Hotel ABC start website by which their customers can reserve or cancel the

room online but there is one problem if customer wants to prepone,postpone or cancel their schedule there are not able to do. Write a procedure to help theircustomer. Write a procedure which takes customer name, contact no, updated date,

updated days as a parameter and reschedule the reservation. Write a procedure which takes customer name and contact no as a

parameter and provide a functionality to cancel the appointment. Refer the below tables for your operations: Customer(cno,name,address,contactno,emailed,adharno/pancard) RoomDetail(rno,rtype,amountperday,totalroom) Reservation(booking id,cno,checkindate,noofdays,totalamount)

5. The Library system of UTU provides facility to issue and return book to student. Student can keep the book for 20 days. If the number of days has exceeded 20 then student has to pay the fine, the fine is calculated as follows : Up to 7 days : 50 paisa per day 8- 20 days: RS. 1 per day(to be counted from the 8th day onwards) More than 20: RS. 1.5 per day((to be counted from the 20th day onwards)

Consider Table: Issue (EnrollNo, BookNo, IssueDate, ReturnDate, Total_Days)

Page 8: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 8

Fine (RollNo, FineAmt) Write a procedure to generate the report about student’s details and the amount of fine to be paid. After calculating the fines store the required information in FINE table. 6. In ABC organization each employee is identified by unique employee code and

Net Salary of the employee is given based on their employee code. Write a procedure which takes employee code as a parameter and insert the calculated DA, MA, PF, IT and NET_Salary into Emp_intensive table. Criteria to calculate Net salary are as follows:

• Net salary = Basic salary + DA + MA – PF – IT

Employee code

DA MA PF IT

1 to 5 67% of BS 12% of BS 10% of BS 15% of BS

6 to 12 62% of BS 10% of BS 9% of BS 10% of BS

13 to 15 55% of BS 8% of BS 8% of BS 8% of BS

Note: DA, MA, PF and IT are given in percentage of basic salary which is given in employee table.

Objective(s) To know the use of function and procedure concepts.

Pre-requisite To understand the parameterized Procedural concept.

Duration 6 hour

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO3: Design user defined functions and stored procedures using procedural SQL.

Solution must contain Procedure.

Nature of submission Handwritten

References http://www.mysqltutorial.org/mysql-stored-procedure-tutorial.aspx

Post Laboratory

questions

Post Laboratory questions: 1. State difference between IN, OUT and INOUT keyword respect to procedure. 2. How to call parameterized procedure? 3. How procedure returns a value?

How to drop procedure?

Assessment

Desired objective(s) satisfied? [Yes/No/Partial]

Verified By

Use of IN /OUT /INOUT parameter

Use of Parameterized Procedure

Page 9: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 9

Practical No: 6 Enrolment No:

Practical Problem 1. Mr. Patel wants to know number of passed student in particular department of university. Create function f_getstudent() that take coursename as input parameter and returns the total number of passing students in that particular course. Consider following table Stud(sid, course, passingpercent, percentscored,result)

2. Manager of “Sahaj superstore” wants to identify total available product in their store. It’s very hard to identify manually so create one function that return number of available product. And also need to identify total number of products belonging to that category using f_getTotalProd() {take category as a parameter} [create two separate function for above functionality]

3. Create a function Write a function that accept class_id and return total students in that class where name begins with H . Consider tables: Student(s_id,name,c_id), Class(c_id,classname)

4. Consider Table: Recharge_Master(rid, cid, mobile_no, Recharge_amount) Write a function which takes mobile_no as an input parameter and returns total recharge paid till the day in that number.

5. Create procedure which takes MobileNo and balance as an argument. Update and returns the balance of user and Insert appropriate record on MobileStatus Table on the basis of following criteria. If balance exceeds 500 then the status = ‘Platinum’, If balance exceeds 400 then the status = ‘Gold’ If balance exceeds 300 then the status = ‘Silver’.

Tables: MobileUser (UserID,UserName,MobileNo, Balance),MobileStatus(MobileNo, status)

Objective(s) To know the use of function and procedure concepts.

Pre-requisite To understand the function concept.

Duration 4 hours

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO3: Design user defined functions and stored procedures using procedural SQL.

Solution must contain Function.

Nature of submission Handwritten

Post Laboratory questions

Post Laboratory questions: 1. What is function? 2. State two difference between procedure and function. 3. Can function return multiple values? Justify. 4. How to call function?

Assessment

Desired objective(s) satisfied? [Yes/No/Partial]

Verified By

Prepare Function

Knowledge of function and procedure

Page 10: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 10

Practical No: 7 Enrollment No:

Practical Problem 1. Counselor of 2nd semester wants to check total numbers of leave applied by

each student and total number of granted leave of each student. Write a procedure which takes counselor name as a parameter and implement above functionality and display information in a proper format. [Must use concept of cursor] Consider table: Student(Sid,Sname,Class,Sem,cid), Leave_master( Lid, LeaveType, Stud_id, Reason, Status), Counselor(cid,cname)

2. Consider Table: ResultMaster(sid, course, passingpercent, percentscored, result) a. Create a procedure proc_passPercent() that takes coursename and new

passing percentage as input parameter, based on which the passingpercent of that course will be updated and accordingly the result of concerned student would also get updated . [Usage of CURSOR is must.]

b. Create a function f_getPassedStud() that takes coursename as input parameter and returns the total number of students passed in that course.

3. Consider table : Mobile_master(ModelNo, ModelName, Price, Company) Write a procedure to count total number of Samsung mobile whose price Less than 5000, 5000-10000, 10000-20000, above 20000. (Use of Cursor Must) Example : display message like Number of mobiles whose price less than 5000 = 2 Number of mobiles whose price between 5000-10000 = 4 Number of mobiles whose price between 10000-20000 = 5 Number of mobiles whose price greater than 20000 = 2 4. Virat kholi wants to know graft of his batting of IPL.He needs to identify number of half centenary, centenary and total score of his IPL match. Consider following table(playerno,teamname,playername,score,date) -----Virat’s dashboard------------- Number of time he scored 0 only :1 Number of time he scored less than 50:6 Number of time max score than 50:60 Number of time max score between 50-100:40 Number of time max score between 100-200:15 Number of time max score greater than 200:7

Objective(s) To know the use of cursor concepts.

Pre-requisite To understand the join query.

Duration for completion

5 hours

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

Page 11: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 11

CO(s) to be achieved CO4: Understand the cursor data types and its usage.

Solution must contain Procedure with cursor.

Nature of submission Handwritten

Post Laboratory questions

Post Laboratory questions: 1. What is cursor? 2. How weekly type cursor is declared? 3. Write advantages and disadvantages of cursor. 4. How cursor is differs from FOR statement?

Assessment

Desired objective(s) satisfied? [Yes/No/Partial]

Verified By

Use of cursor

Use of DML statement in cursor

Page 12: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 12

Practical No: 8 Enrollment No:

Practical Problem 1. Write a trigger to calculate total_loss_match based on played and win match, whenever any record is inserted into cricket table. Consider Tables: Cricket(cid, TeamName, Captain, played_match, total_win_match, total_loss_match) [Note: Total_loss_match value must be null while inserting data in table.]

2. Write a trigger that calculates total, percentage and grade of that student whenever record is inserted into student.[Total,per,grade must be null while inserting data] Consider Tables: Student (id, name, class, m1, m2, m3,total,per,grade)

3. Write a trigger that calculates inst_Amt based on installment and LoanAmount of loan whenever any record is inserted on Loan table. Table : Loan(Cid, Lid, LoanAmount, installment, inst_amt, inst_over)

4. Create trigger to insert record into ExEmployee table whenever any record deleted from employee table. Consider Tables: Employee (EmpId,EmpName,City,Salary,Status) ExEmployee (EmpId,EmpName,City)

Consider table : Prod_master(pId, pname, quantity, cost_price, sale_price, profit, loss), Audit_log(pid, pname, cdate,action), [Note: while inserting values in Prod_Master, Profit and Loss value must be null.Date=>current date, action =>delete, update] 5. Write a trigger to calculate and insert profit or loss whenever new record is

inserted into prod_master. 6. Write a trigger that insert record into audit_log table whenever any record

deleted from prod_master. 7. Write a trigger that insert record into audit_log table whenever any changes in

prod_master. 8. Government has issue a new rules to calculate net salary of each employee.

Employee net salary is calculated based on the basic salary of the employee where allowances and deduction calculated using following information HRA = 7.5% of salary, DA = 67% of salary, MA = 1.5% of salary Gross = Salary + HRA + DA + MA PF is 8.33% of salary Net salary = gross – pf - tax Tax is calculated based on following criteria.

Gross Tax

<= 1 Lack 0

1.00 - 1.50 lack 7.5%

1.51 - 2.00 Lack 10%

> 2.00 Lack 15%

For example

if gross is 1.2 lacks than tax will be calculated on 20000 @ 5%,

If gross is 2.5 lacks than for first lack tax is zero for next 50000 taxes will be @7.5%, for next 50000 taxes will be @10 % and for last 50000 taxes will be calculated @ 15%.

Write a trigger to implement above functionality whenever any record is inserted into Employee table and calculate HRA, DA, MA, gross, tax, PF, net salary based on salary.

Page 13: Babu Madhav Institute Of Information Technology 2016 …utu.ac.in/BMIIT/StudentCorner/2016-17/Sem2/060010209_PL.pdf · Babu Madhav Institute Of Information Technology 2016-2017 Ms.Preeti

Babu Madhav Institute Of Information Technology 2016-2017

Ms.Preeti Bhatt, Ms.Hinal Shah Page 13

9. Write a trigger which is prohibiting delete operation to user whose id is 007. 10. Write a trigger which check whether the empno is unique or not and empno

should be start with ‘e’. If the condition is not satisfydon’t allow to insert a record in the emp table.

Objective(s) To know the use of trigger concepts.

Pre-requisite To understand the concept of tables.

Duration for completion 5 hours

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO4: Demonstrate creating and firing of triggers.

Solution must contain Trigger.

Nature of submission Handwritten

Post Laboratory questions

Post Laboratory questions: 1. When before trigger is used? 2. Differentiate before trigger and after trigger? 3. What is the use of OLD and NEW keyword? 5. When trigger is executed? Can we call explicitly?

Assessment

Desired objective(s) satisfied? [Yes/No/Partial]

Verified By

Use of trigger

Provide DML constraints