Upload
others
View
8
Download
0
Embed Size (px)
Citation preview
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 1
5 Years Integrated M.Sc.(IT) – Semester 2 Practical Problems
060010202 – Relational DBMS
Practical No: 1 Enrollment No: All Students
Practical Problem Create the following table:
Supplier (Supplier_Id,Supplier_Name,City,Contact_Number,State) Item (Item_Id,Item_Name,Quantity,Colour,Supplier_Id,MFG_Date)
Make Supplier_Id of Supplier & Item_Id of Item table as Primary key. Apply necessary constraints while creating tables.
Supplier_Id as foreign key in Item table.
Quantity should be between 50 and 100.
City must be from “Surat”,”Bardoli”,”Baroda”,”Navsari”.
Supplier_ID should be start with ‘S’. Insert at least five records in each tables: Perform following queries:
1. Change the item_id ‘I004’ whose Supplier_Name is “Smith”. 2. Find Item_Name having quantity more than 150 and colour
“Red”. 3. Display supplier city who supply Item_Name “Eraser”.
4. List the supplier name who supply item having initial
character as ‘A’.
5. Display total item from each supplier wise.
Objective(s) To understand the concept of Join and GROUP BY clause.
Pre-requisite To knowledge about joins and GROUP BY clause.
Duration for completion 2 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 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
Beginning DB2: From Novice to Professional, Allen G.
http://w3schools.com/Sql/
Post Laboratory
questions
Post Laboratory questions: 1. What is use of JOIN clause? 2. Solved 3rd query without JOIN clause. 3. Can JOIN clause work with update statement? Justify. 4. Solved 1st query with use of sub-query.
Assessment
Solution achieves the desired Viva
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 2
objective(s)
Out of Marks 10 5
Secured by the student
Signature
Date
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 3
Practical No: 2 Enrollment No: All Students
Practical Problem 1. Create student table and insert at least three records.
Student( Sid, Sname, Contactno, City, State)
a. Write a block that accept S_id from user and display
Contactno of that student.(Use concept of anchor
datatype)
b. Write a block to insert the user inputted value into student
table using row variable.
2. Create an Author table and insert at least three records. Author
(Author_id,Name,City,State,Specialization,No_Of_Book_Publish)Consider
above table and solved below block.
a. Write a block that accept Author_id from user and display
No_of_book_publish by author. (Use concept of anchor
datatype).
b. Write a block to insert the user inputted value into Author
table using row variable.
Objective(s) To know the syntax of all data types.
Pre-requisite To understand the concept of RDBMS data types.
Duration for completion 3 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 CO1: Differentiate DBMS & RDBMS and use SQL data types.
Solution must contain Data types statements.
Nature of submission Handwritten
References for solving
the problem
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
Post Laboratory
questions
Post Laboratory questions: 1. Perform q-1(b) without using row variable. 2. Can ANCHOR data type work like row of table or view? 3. Which clause is used to define ANCHOR datatype? 4. Which package is used to display statement?
Assessment
Solution achieves the desired objective(s)
Viva
Out of Marks 10 5
Secured by the student
Signature
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 4
Date
Practical No: 3 Enrollment No: All Students
Practical Problem
1) Write SQL/PL block that accept string from user and find out the length of these string.
2) Write SQL/PL block that taken input as five subject marks. Find percentage
Print message using following condition. 1) >= 70 then “Distinction” 2) >=60 then “First class” 3) >= 50 then “Second class” 4) >= 40 then “Pass class” 5) < 40 then “Fail”
3) Write SQL/PL block that accept three numbers from user and display maximum number.
4) Create table student (Student_id,Name,Grade)
Student_id Name Grade
1 Amit A
2 Amita C
3 Amitabh B
4 Ami A
Write block that accept student_id from user and check grade and print appropriate message. Grade – ‘A’-> Excellent Grade – ‘B’ -> Very good Grade – ‘C’ -> Good Grade – ‘D’ -> Average Grade- ‘F’ -> Fail
Objective(s) To understand the concept of IF statement.
Pre-requisite Students able to understand the working and use of if statement.
Duration for completion 3 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 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 for solving
the problem
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 5
Post Laboratory
questions
Post Laboratory questions: 1. What is syntax error occurs when forgot semicolon at End IF
statement? 2. In Boolean expression required comparison operator? 3. What changes will be made in block no two if passing
percentage is less than 50? 4. List out four types of IF statement.
Assessment
Solution achieves the desired objective(s)
Viva
Out of Marks 10 5
Secured by the student
Signature
Date
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 6
Practical No: 5 Enrollment No: All Students
Practical Problem
1) Write SQL/PL block that taken input as five subject marks. Find percentage( using case statement)
Print message using following condition. Percentage >= 70 then “Distinction” Percentage >=60 then “First class” Percentage >= 50 then “Second class” Percentage >= 40 then “Pass class”
Percentage < 40 then “Fail” 2) Create a Bank_account table in insert at least three records Bank_account( Account_no,Branch_name,Balance) Write block that will accept an account number from the user, check following condition.
a) Increase Rs.500/- from the balance if the users balance is less than Rs.5000.
b) Increase Rs.300/- from the balance if the users balance is less than Rs.10000.
c) Increase Rs.100/- from the balance if the users balance is less than Rs.20000.
Objective(s) To understand the concept of case statement.
Pre-requisite Students able to understand the working and use of case statement.
Duration for completion 2 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 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 for solving
the problem
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
Post Laboratory
questions
Post Laboratory questions: 1. What changes can be made in problem-5(2) to deduct 10% of
balance from the balance? 2. When no any case statement match then which clause is
executed? 3. Which sign is used to taken input from user? 4. What is advantage of case statement over if statement?
Assessment
Solution achieves the desired objective(s)
Viva
Out of Marks 10 5
Secured by the student
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 7
Practical No: 6 Enrollment No: All Students
Practical Problem 1) Write a SQL/PL code block to calculate the area of circle for a value of radius varying from 3 to 7. Store the radius and the corresponding values of calculated area in an empty table named Circle_Area, consisting of two columns Radius and Area. 2) Write a SQL/PL code block to calculate area of Triangle for a value of height varying from 10 to 20. Area of Triangle= ½ × b × h and Take h=10. Store the base, height and the calculated area in an empty table named Triangle_Area, consisting of three columns Base, Height and area.
Objective(s) To know the use of while statement.
Pre-requisite To understand the looping concept.
Duration for completion 2 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 CO2: Use of IF, CASE, FOR, LOOP, WHILE and REPEAT control flow
statements.
Solution must contain Block using while loop
Nature of submission Handwritten
References for solving
the problem
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
Post Laboratory
questions
Post Laboratory questions: 1. What is the use of while loop? 2. When while loop is terminated? 3. What change can be done if we find area of circle from radius
5 to 10? 4. What change can be done if we find area of triangle with
height varies from 30-40 and base=30?
Assessment
Solution achieves the desired objective(s)
Viva
Out of Marks 10 5
Secured by the student
Signature
Date
Signature
Date
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 8
Practical No: 7 Enrollment No: All Students
Practical Problem 1) Consider table : Employee (Id, Name, Salary, Department) Write block to count number of employee of marketing department whose salary Less than 10000, 10000-20000, 20000-30000, above 30000. Example : Display message like salary less than 10000 = 0 salary between 10000-20000 = 1 salary between 20000-30000 = 1 salary greater than 30000 = 2 2)Consider table : Loan(CustomerId,CustomerName, LoanType, Amount, No_of_Installment) Note: Loan Type should be Home/Educational loan Write a block to count total number of customer who apply for educational loan whose loan amount Less than 50000, 50000-100000, 100000-200000, above 200000. Example : display message like Number of customer whose educational loan less than 50000 = 5 Number of customer whose educational loan between 50000-100000 = 2 Number of customer whose educational loan between 100000-200000 = 4 Number of customer whose educational loan greater than 200000 = 1
Objective(s) To know the use of FOR statement.
Pre-requisite To understand the looping concept.
Duration for completion 3 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 CO2: Use of IF, CASE, FOR, LOOP, WHILE and REPEAT control flow
statements.
Solution must contain Block using for loop.
Nature of submission Handwritten
References for solving
the problem
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
Post Laboratory Post Laboratory questions:
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 9
questions 1. What is the use of for loop? 2. Which statement is used to terminate FOR loop? 3. Which data type is used to store record from for loop? 4. What changes can be made in above problem if want to fetch
no of employee of “Finance” department?
Assessment
Solution achieves the desired objective(s)
Viva
Out of Marks 10 5
Secured by the student
Signature
Date
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 10
Practical No: 8 Enrollment No: All Students
Practical Problem 1. Consider table : Mobile_master(ModelNo, ModelName, Price, Company) Write a block 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 2.Consider table : Cricket (PlayerId, PlayerName, Max_score, Country) Write a block to count Indian players whose maximum scores Less than 50, 50-100, 100-200, above 200. (Use of Cursor Must) Example : display message like Number of players whose Max score less than 50 = 2 Number of players whose Max score between 50-100 = 4 Number of players whose Max score between 100-200 = 5 Number of players whose Max score greater than 200 = 2
Objective(s) To know the use of cursor predicates.
Pre-requisite To understand the cursor concept.
Duration for completion 3 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 CO2: Use of IF, CASE, FOR, LOOP, WHILE and REPEAT control flow statements.
Solution must contain Block using for cursor.
Nature of submission Handwritten
References for solving the problem
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
Post Laboratory questions
Post Laboratory questions: 1. What are the predicates of cursor? 2. What is the use of SET and FETCH statement of cursor? 3. Perform above example using strongly type cursor. 4. Differentiate strongly and weakly type cursor.
Assessment
Solution achieves the desired objective(s)
Viva
Out of Marks 10 5
Secured by the student
Signature
Date
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 11
Practical No: 9 Enrollment No: All Students
Practical Problem
Consider table: Job (Job_no, Type_of_Job, Status) Write a function, which returns the total number of incomplete jobs. Job must have values ‘I’ or ‘C’. Note: Don’t use count function. Consider table: Loan (Cid, Lid, Amount, Instalment, Inst_amount, Inst_over) Write a function that accept customer id as an argument and find remaining instalment that he has to pay. Eg: If amount=100000 and instalment=20 then=> Inst_amount=5000.
Objective(s) To know the use of function
Pre-requisite To understand the concept of cursor and conditional and control
statement.
Duration for completion 2 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 Block using cursor and FOR loop
Nature of submission Handwritten
References for solving
the problem
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
Post Laboratory
questions
Post Laboratory questions: 1. Write the use of CONTANTS SQL DATA in function? 2. Solved practical no (9) using count function. 3. Can function returns multiple values? Justify. 4. Write the use of READS keyword in function.
Assessment
Solution achieves the desired objective(s)
Viva
Out of Marks 10 5
Secured by the student
Signature
Date
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 12
Practical No: 10 Enrollment No: All Students
Practical Problem Consider tables: Empbranch(empno,Designation,Basic_sal,DOB,B_code) Branch(B_code,City) Create above tables and insert at least 3 records. Write a procedure that takes city and designation as input parameter. This procedure gives 10% bonus to all employees belonging to that city and having that designation. Note: (Use Cursor) Consider tables: Book (ISBN_NO,Title,Publication,Release_date,Author_id,Price) Author (Author_id,Name,specialization,No_of_book_publish) Create above tables and insert at least 3 records. Write a procedure that accept specialization as input parameter and display book details.(Use proper format to display book information) (Note: Use Cursor)
Objective(s) To know the use of procedure with cursor
Pre-requisite To understand the concept of cursor
Duration for completion 3 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 Block using cursor and FOR loop
Nature of submission Handwritten
References for solving
the problem
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
Post Laboratory
questions
Post Laboratory questions: 1. Can returns keyword used in procedure? Justify. 2. Solved practical no (10) without using cursor. 3. What is use of OUT keyword in procedure? 4. Can we activity procedure automatically? Justify.
Assessment
Solution achieves the desired objective(s)
Viva
Out of Marks 10 5
Secured by the student
Signature
Date
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 13
Practical No: 11 Enrollment No: All Students
Practical Problem Consider tables :
Book_master(bid, title, author, no_of_copy, cost_price, sale_price,
profit,loss)
Audit_log(bid, cdate, action)
Cdate=>current date, action =>delete.
a. Write a trigger to calculate and insert profit or loss whenever new
record is inserted into Book_master.
b. Write a trigger that insert record into audit_log table whenever any
record deleted from Book_master.
Student ( Id,Name,Class,Sub1,Sub2,Sub3) Stud_Details ( Id,Total,Percentage,Grade) a) Write a trigger that calculate total, percentage and grade of that student and inserted into stud_details whenever record is inserted into student.
Consider tables: Stud (Id,name,class) Stud_log(Id,class) b) Write a trigger that insert record into Stud_log table whenever any
recorded deleted from stud table.
Objective(s) To know the use of function
Pre-requisite To understand the concept of cursor and conditional and control
statement.
Duration for completion 3 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 Conditional statement
Nature of submission Handwritten
References for solving
the problem
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
Post Laboratory
questions
Post Laboratory questions: 1. On which basis triggers gets activated when multiple triggers
are defined on one table? 2. List out possible triggering events.
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 14
3. Write signification of “CREATE OR REPLACE” together. 4. Write the use of CONTAINS SQL DATA in function.
Assessment
Solution achieves the desired objective(s)
Viva
Out of Marks 10 5
Secured by the student
Signature
Date
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 15
Practical No: 12 Enrollment No: All Students
Practical Problem Consider table : Manager (manager_id, name, wage_per_hour, dept) Worker (worker_Id, name, wage_per_hour,manager_id) 1) Write a procedure to display all the workers whose earning is more than his manager. Employee(Eid, Ename, Dept, basic_Salary, HRA, PF , Net_Salary) 2) Write a trigger that calculates HRA, PF, Net_Salary based on basic salary whenever any record is inserted on Employee table. HRA: 40% of basic salary PF: 12% of basic salary Net_Salary=Basic_Salary+HRA+PF. 3) Consider tables: Patient(Pid,Name,Address) Room(Rno,Type,Charge) Doctor(Dno,Name,Specialist) Patient_info(Pid,Gender,Blood_group,Diseases,Rno,Dno) Note(Specialist like: general,eye,cancer,heart) (Type: Economical:500,Semi-Special:1000,Special:1500) a) Write a procedure to change the doctor from all the patient information who is taking treatment from Dr.Vyas to Dr.Desai. b) Write a procedure to delete all the patients’ information that is in special room and semi-special room.
Objective(s) To know the use of procedure with cursor
Pre-requisite To understand the concept of cursor
Duration for completion 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 Block using cursor and FOR loop
Nature of submission Handwritten
References for solving
the problem
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
Post Laboratory
questions
Post Laboratory questions: 1. Can instead of trigger work with table? Justify 2. Write use of modifies, contains and reads sql data in function.
Department of Computer Science and Technology, UTU- 2015
Ms. Ankita Patel Page 16
3. Can function return multiple values? Justify. 4. Write a difference between trigger and procedure.
Assessment
Solution achieves the desired objective(s)
Viva
Out of Marks 10 5
Secured by the student
Signature
Date