23
Laboratory Manual (Version 1.0) for Database Management Systems Lab (MCA-165) MCA - I Semester Compiled by: Dr. Vaishali Joshi (Assistant Professor, BVICAM, New Delhi) Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM) A-4, Paschim Vihar, Rohtak Road, New Delhi-63 Visit us at: www.bvicam.in

Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual (Version 1.0)

for

Database Management Systems Lab (MCA-165)

MCA - I Semester

Compiled by:

Dr. Vaishali Joshi (Assistant Professor, BVICAM, New Delhi)

Bharati Vidyapeeth’s

Institute of Computer Applications

and Management (BVICAM)

A-4, Paschim Vihar, Rohtak Road, New Delhi-63 Visit us at: www.bvicam.in

Page 2: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-156; Database Management Systems Lab. | Version 10.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi | Page 2 of 23

Index

List of Abbreviations

Declaration

1. Vision of the Department 5

2. Mission of the Department 5

3. Programme Educational Objectives (PEOs) 5

4. Programme Outcomes (POs) 6

5. Institutional Policy for Students’ Conduct 5

6. Learning Outcomes of Laboratory Work 9

7. Course/Lab Outcomes (COs) 9

8. Mapping of COs with POs 10

9. Course/Lab Description 10

10. Grading Policy 11

11. Lesson Plan 11

12. Assignments 12

Appendix

Page 3: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-165; Database Management Systems Lab. | Version 1.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi Page 3 of 23

List of Abbreviations

BTL Bloom’s Taxonomy Level

CE Communication Efficacy

CICP Conduct Investigations of Complex Computing Problems

CK Computational Knowledge

CO Course Outcome

DAC Departmental Advisory Committee

DDS Design and Development of Solutions

I&E Innovation and Entrepreneurship

I&T Individual & Team Work

IQAC Internal Quality Assurance Cell

LLL Life-Long Learning

MTU Modern Tool Usage

PA Problem Analysis

PE Professional Ethics

PEO Programme Educational Objective

PL/SQL Programming Language / Structured Query Language

PMF Project Management and Finance

PO Programme Outcome

SEC Societal and Envoirnmental Concern

SQL Structured Query Language

Page 4: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-156; Database Management Systems Lab. | Version 10.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi | Page 4 of 23

Declaration

Department : Department of Computer Science and Applications

Course, Year and the

Semester to which Lab is

offered

: MCA - I Year, I Semester

Name of the Lab Course : Database Management Systems Lab

Course Code : MCA-165

Version No. : 1.0

Name of Course/Lab

Teacher

: Dr. Vaishali Joshi

Laboratory Manual

Committee

: 1. Dr. Vaishali Joshi, Chairperson

2. Dr. Anupam Baliyan, Member

3. Dr. Ritika Wason, Member

4. Mrs. Tanya Pathak Garg, Member

5. Mr. Uttam Singh Bist, Member

6. Prof. P. S. Grover, Margdarshak

7. Mr. Amit Sharma, Alumni & Industry Expert

8. Dr. Ritika Wason, Concerned Subject Teacher,

Convener

Approved by : DAC Date:

Approved by : IQAC Date:

Signature

(Course Teacher)

Signature

(Head of Department)

Signature

(IQAC Coordinator)

Page 5: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-165; Database Management Systems Lab. | Version 1.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi Page 5 of 23

1. Vision of the Department

To become a Centre of excellence in the field of Computer Science and Applications,

to contribute effectively in the rapidly changing global economy directed towards

national development ensuring prosperity for the mankind.

2. Mission of the Department

M1 To become a centre of excellence in the field of Computer Science and

Applications and produce professionals as per global industry standards.

M2 To foster innovation, entrepreneurial skills, research capabilities and bring

all-round development amongst budding professionals.

M3 To promote analytical and collaborative life-long learning skills, among

students and faculty members involving all stakeholders.

M4 To inculcate strong ethical values and professional behaviour while giving

equal emphasis to social commitment and nation building.

3. Programme Educational Objectives (PEOs)

The PEO’s for the MCA programme are as follows:

PEO1 Exhibit professional competencies and knowledge for being a successful

technocrat.

PEO2 Adopt creative and innovative practices to solve real-life complex problems.

PEO3 Be a lifelong learner and contribute effectively to the betterment of the

society.

PEO4 Be effective and inspiring leader for fellow professionals and face the

challenges of the rapidly changing multi-dimensional, contemporary world.

Page 6: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-156; Database Management Systems Lab. | Version 10.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi | Page 6 of 23

4. Programme Outcomes (POs)

PO1:

Computational Knowledge (CK)

Demonstrate competencies in fundamentals of computing, computing

specialisation, mathematics, and domain knowledge suitable for the

computing specialisation to the abstraction and conceptualisation of

computing models from defined problems and requirements.

PO2:

Problem Analysis (PA)

Identify, formulate, and analyze complex real-life problems in order to arrive

at computationally viable conclusions using fundamentals of mathematics,

computer sciences, management and relevant domain disciplines.

PO3: Design and Development of Solutions (DDS)

Design efficient solutions for complex, real-world problems to design

systems, components or processes that meet the specifications with suitable

consideration to public health, and safety, cultural, societal, and

environmental considerations.

PO4: Conduct Investigations of Complex Computing Problems (CICP)

Ability to research, analyze and investigate complex computing problems

through design of experiments, analysis and interpretation of data, and

synthesis of the information to arrive at valid conclusions.

PO5: Modern Tool Usage (MTU)

Create, select, adapt and apply appropriate technologies and tools to a wide

range of computational activities while understanding their limitations.

PO6: Professional Ethics (PE)

Ability to perform professional practices in an ethical way, keeping in mind

cyber regulations & laws, responsibilities, and norms of professional

computing practices.

PO7: Life-Long Learning (LLL)

Ability to engage in independent learning for continuous self-development

Page 7: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-165; Database Management Systems Lab. | Version 1.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi Page 7 of 23

as a computing professional.

PO8: Project Management and Finance (PMF)

Ability to apply knowledge and understanding of the computing and

management principles and apply these to one’s own work, as a member

and leader in a team, to manage projects in multidisciplinary environments.

PO9: Communication Efficacy (CE)

Ability to effectively communicate with the technical community, and with

society at large, about complex computing activities by being able to

understand and write effective reports, design documentation, make

effective presentations, with the capability of giving and taking clear

instructions.

PO10: Societal and Envoirnmental Concern (SEC)

Ability to recognize and assess societal, environmental, health, safety, legal,

and cultural issues within local and global contexts, and the consequential

responsibilities applicable to professional computing practices.

PO11: Individual & Team Work (I&T)

Ability to work in multi-disciplinary team collaboration both as a member

and leader as per need.

PO12: Innovation and Entrepreneurship (I&E)

Ability to apply innovation to track a suitable opportunity to create value

and wealth for the betterment of the individual and society at large.

5. Institutional Policy for Students’ Conduct

The following guidelines shall be followed:-

5.1 All the students in their introductory Lab. shall be assigned a system, which

shall be their workplace for the complete semester. Students can store records

of all their Lab. assignments on their individual workstations.

5.2 Introductory Lab. shall include an introduction to the appropriate

software/tool, followed by a basic Introductory Assignment having Practice

Page 8: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-156; Database Management Systems Lab. | Version 10.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi | Page 8 of 23

Questions. All the students are expected to complete this assignment within a

week time, as the same shall be assessed through a lab. test.

5.3 Each week the instructor, in parallel to respective topics covered in the theory

lecture, shall assign a set of practical problems to the students in form of

Assignments (A, B, C, .....). The problems in these assignments shall be divided

into two parts. The first set of Problems shall be compulsory for all the students

and its record need to be maintained in the Prcatical File, having prescribed

format, as given in Appendix-A. All the students should get the weekly

assigntment checked and signed in the Practical File by the respective teacher in

the immediate succeeding week. The second set of problems are Advanced

Problems and shall be optional. Student may solve these advanced problems

for their further practice.

5.4 Cellular phones, pagers, CD players, radios and similar devices are prohibited

in the classrooms, laboratories and examination halls.

5.5 Laptop-size computers / Tablets may be used in lectures for the purpose of

taking notes or working on team-projects.

5.6 The internal practical exam shall be conducted towards the end of the semester

and shall include the complete set of Lab exercises conducted as syllabus.

However, students shall be assessed on continuos basis through overall

performances in regular lab. tests, both announced and surprise and viva-voce.

5.7 The respective faculty shall prepare and submit sufficient number of practical

sets of computing problems to the Dean (Examinations), atleast two weeks

prior to the actual exam. It is the responsibility of the faculty to ensure that a set

should not be repeated for more than 5 students in a given batch.

5.8 The exam shall be of 3 hours duration where the student shall be expected to

implement solutions to his/her assigned set of problems on appropriate

software tools in the lab.

Page 9: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-165; Database Management Systems Lab. | Version 1.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi Page 9 of 23

5.9 Once implemented, student shall also appropriately document code

implemented in the assigned answer sheets, which shall be submitted at the

end of the examination. All the students shall also appear for viva-voce

examination during the exam.

5.10 Co-operate, Collaborate and Explore for the best individual learning outcomes

but copying or entering into the act of plagiarism is strictly prohibited.

6. Learning Outcomes of Laboratory Work

The student shall demonstrate the ability to:

Verify and Implement the concepts and theory learnt in class.

Code and use Software Tools to solve problems and present their optimal

solutions.

Apply numerical/statistical formulas for solving problems/questions.

Develop and apply critical thinking skills.

Design and present Lab as well as project reports.

Apply appropriate methods for the analysis of raw data.

Perform logical troubleshooting as and when required.

Work effectively as a member of a team in varying roles as need be.

Communicate effectively, both oral and written.

Cultivate ethics, social empathy, creativity and entrepreneurial mindset.

7. Course/Lab Outcomes (COs) CO1 Translate an information model into a relational database schema and to

implement the schema using RDBMS. (BTL2)

CO2 Apply advanced SQL features like views, indexes, synonyms, etc. for database

(BTL3)

Page 10: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-156; Database Management Systems Lab. | Version 10.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi | Page 10 of 23

CO3 Analyze PL/SQL structures like functions, procedures, cursors and triggers for

database applications. (BTL4)

CO4 Examine database administration concepts like GRANT, REVOKE etc. through

SQL commands. (BTL4)

CO5 Work in teams to design solutions for real world problems/case studies by

creating efficient database schema.. (BTL6)

8. Mapping of COs with POs

Table 1: Mapping of COs with POs

PO/CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12

CO1 3 3 2 - 3 - - - - 3 - -

CO2 3 2 2 - - 2 - - - 3 - -

CO3 3 2 2 - - 2 - - - 3 - -

CO4 3 3 3 2 - - - - - 3 - -

CO5 3 3 3 2 3 2 2 3 3 3 3 -

9. Course/Lab Description

Course (Lab) Title : Database Management Systems Lab.

Course (Lab) Code : MCA-165

Credits : 01

Pre-requisites : Elementary Maths (Sets, Relations)

Basic Data Structure Concepts

Academic Session : January to June

Contact Hours/Week : 02 (01 Lab of 02 hours each/Week)

Internal Assessment : 40 Marks

External Assessment : 60 Marks

Page 11: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-165; Database Management Systems Lab. | Version 1.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi Page 11 of 23

10. Grading Policy

Item Points Marks Remarks

Weekly Lab Assignments

including Practical Files

10 10 Closed Book/Open Book

Internal End-Term Practical

Examination

20 10 Closed Book

Viva-Voce 20 10 Closed Book

External End-Term

Examinations

60 60 Closed Book (conducted and

evaluated by the University)

Total 100

11. Lesson Plan

Week No.

Lab No. Topics / Concepts to be Covered

Reference of Lab Manual

1. 1. Basic DDL/DML queries, views and sub-

queries

Assignment A

(Problem AP1)

2. 2. Advanced SQL queries based on

Constraints, Sequences, Indexes and

Union, Intersect and Minus clauses

Assignment A

(Problem AP2)

3. 3. Joining tables in SQL for fetching desired

records

Assignment B

(Problem BP1)

4. 4. Using Built-in functions

Assignment C

(Problem CP1)

5. 5. Buffer Reserved for Revision Assignment A - C

Page 12: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-156; Database Management Systems Lab. | Version 10.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi | Page 12 of 23

12. Assignments

Assignment Set: A

Objectives of the Assignment:

• To familarize with DDL and DML commands.

• To access desired records from tables, using where clauses with different

operators and using nested queries.

• To apply integrity constraints at table level and column level.

CO/BTLCovered: CO1/ BTL3

Problems:

AP1 Consider the following table:

6. 6. Basic PL/SQL programs

Assignment D

(Problem DP1 – DP3)

7. 7. Transaction management – using

savepoint, rollback and commit

Assignment D

(Problem DP4 – DP5)

8. 8. Implicit and Explicit cursors

Assignment E

(Problem EP1– EP2)

9. 9. Implicit and Explicit cursors with

Exception handling

Assignment E

(Problem EP3– EP4)

10. 10. Buffer Reserved for Revision Assignment D - E

11. 11. Procedures and Functions

Assignment F

(Problem FP1– FP4)

12. 12. Before and After Triggers Assignment G

(Problem GP1– GP2)

13. 13. Buffer Reserved for Revision Assignment F - G

Page 13: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-165; Database Management Systems Lab. | Version 1.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi Page 13 of 23

Table : Book

Field Name Data type Size Constraint

Book_Code Varchar2 5 Primary key

ISBN No. Varchar2 8 Not Null/

Book_Name Varchar2 8 Unique

Publisher Varchar2 6

Price Number 5,2 >=100

Author_Name Varchar2 8

Date_of_Launch Date

Write queries to perform the following:

1. Insert few records in it.

2. Increase the size of the Book_Name field to 10 characters.

3. Display the total price of all the books of “TMH’ publishing house.

4. Display the details of all the books of author “Yashwant Kanetkar” and “Robert

Lafore”.

5. Delete all the books belonging to “PHI” publisher.

6. Update the price of books by 5% which belong to ‘BPB’ publishers.

7. Create a new table “Author” with author details such as author id (primary key),

name of the author, subject, contact details, research area etc.

8. Insert records in it and display the records of those authors who have ‘Web

mining’ as their research area.

9. Add a new column “Author_Id” in “Book” table and make it a foreign key on

“author id” of “Author” table.

10. Update all the previous records of Book table to add information of author id

(newly added column)

11. Display the records of the books where book name starts with ‘C’ or ‘G’ or ‘K’.

12. Create a view for the user to access Book Code, Name and Price of books which

are published by ‘Pearson Education’.

AP2 Consider the following table:

Table : Student

Field Name Data type Size Constraint

Roll_no Number 2 Primary Key

Name Varchar2 20 Not Null

Address Varchar2 50

Page 14: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-156; Database Management Systems Lab. | Version 10.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi | Page 14 of 23

City Varchar2 30

Marks_Sub1 Number 5,2 >=0 and <=100

Marks_sub2 Number 5,2 >=0 and <=100

Marks_sub3 Number 5,2 >=0 and <=100

Total Number 5,2 >=0 and <=300

Write SQL queries for :

1. Insert few records except total marks.

2. Use Sequences for roll_no field.

3. Create a view on the table to access roll no, name (in capitals), Marks of all 3

subjects and Percentage of all the students.

4. Create a view on the table to access roll no, name and total marks of all the

students.

5. Create a view on the table to access roll no, name and total marks of those

students who belong to ‘Delhi’.

6. Create a similar table ‘Scholar’ with same set of attributes.

7. Create a composite index on Student table.

8. Insert few records in ‘Scholar’ table.

9. Use ‘union’ to retrieve all records from both the tables.

10. Use ‘intersect’ to retrieve all uncommon records from both the tables.

11. Use ‘minus’ to retrieve records of one table which do not belong to other table.

Advanced Problems:

AA1 Consider the following table:

Table : Student

Field Name Data type Size Constraint

Roll_no Number 2 Primary Key

Name Varchar2 20 Not Null

Address Varchar2 50

City Varchar2 30

Marks_Sub1 Number 5,2 >=0 and <=100

Marks_sub2 Number 5,2 >=0 and <=100

Marks_sub3 Number 5,2 >=0 and <=100

Total Number 5,2 >=0 and <=300

Write SQL queries for :

Page 15: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-165; Database Management Systems Lab. | Version 1.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi Page 15 of 23

1. Insert few records except total marks.

2. Create a view on the table to access roll no, name and total marks of those

students who belong to ‘Delhi’.

3. Calculate total marks of each student and save it.

4. Display the name of the student who has got the highest marks.

5. Display the records of those students who have got marks more than the marks of

‘Kiran’.

6. Display the percentage of all the students with their names.

7. Display the names of those students who have got maximum marks in sub1 and

more than 50 in sub2 and sub3.

8. Update the marks of all those students who are fail, with grace marks 5. (fail

means less than 40)

9. Delete the record of student who got minimum marks.

10. Display record of student who got second highest marks.

11. Display the average total marks of all the students city wise excluding the

students of ‘Gurgaon’.

12. Get the names of students with Roll_no less than 30 and whose total marks is

more than the total marks of at least one student with Roll_no greater than or

equal to 30.

Assignment Set: B

Objectives of the Assignment:

• To work with joins for joining multiple tables.

• To apply and use primary key and foreign key concepts.

CO/BTLCovered: CO1 & CO2/BTL3 & BTL4

Problems:

BP1 Consider the following three relations: Primary Keys are indicated by # Foriegn Keys are underlined.

Employee (Eid#, EName, Address, DateOfJoining, Department) Project (Pid#, PName, StartDate, TerminationDate) AssignedTo (Eid, Pid)

Page 16: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-156; Database Management Systems Lab. | Version 10.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi | Page 16 of 23

Now write queries for the following in relational algebra as well as in SQL:

1. Find the employees working on ‘Banking’ project.

2. Find the projects assigned to the employees of D01 or D02.

3. Find the employees who belong to Delhi and work on either ‘University’

project or ‘ShareMarket’ project

4. Find the employees who do not work on ‘University’ project.

5. Find the employees who work on all projects.

6. List the employees who have not been assigned any project.

7. Find the employees who joined the department after the commencement of

‘Bank’ project.

8. Display the start and termination date of projects which are allotted to ‘Jai

Prakash’.

Advanced Problems:

BA1 Consider the following relations:

Primary Keys are indicated by # Foriegn Keys are underlined.

Student (Roll#, SName, City, Age, Gender) Course (Cid#, CName, Semester, Credits, Fee) Enrollment (Roll, Cid, DateOfReg) Now write SQL queries for the following: 1. Find the details of students registered in MCA course.

2. Display the total number of students enrolled in MBA.

3. Display the names of students who are enrolled in the course in which

“Anita” is registered.

4. Display the names of all the students with their date of enrollment in the

courses.

5. Display the name of the course in which “Kunal” is registered.

6. Display the names of boys-students enrolled in MCA.

7. Display the number of students registered in MCA course who live outside

Delhi.

Page 17: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-165; Database Management Systems Lab. | Version 1.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi Page 17 of 23

Assignment Set: C

Objectives of the Assignment:

• To familiarize with built-in functions including numeric, character and date

functions.

CO/BTLCovered: CO2/ BTL4

Problems:

CP1 Consider any table of your choice and execute following functions on numeric, character and date type fields :

• sqrt( )

• power( )

• ceil( )

• max( )

• min( )

• avg( )

• count( )

• exp( )

• mod( )

• sum ( )

• floor( )

• abs( )

• greatest ( )

• round( )

• to_date( )

• months_between( )

• last_day( )

• add_months( )

• next_day( )

• sysdate

• round( )

• to_char( )

Page 18: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-156; Database Management Systems Lab. | Version 10.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi | Page 18 of 23

• length( )

• substr( )

• lower( )

• initcap( )

• instr( )

• concat( )

• lpad( )

• rpad( )

• ltrim( )

• rtrim( )

• replace( )

Assignment Set: D

Objectives of the Assignment:

• To familiarize with the structure of PL/SQL programs and learn basic concepts.

• To develop programs based on PL/SQL sontrol structures.

• To apply transaction management using set of savepoint-rollback-commit

statements.

CO/BTLCovered: CO3 & CO4/BTL3

Problems:

DP1 Write a PL/SQL code that will reverse a given number like 12345 to 54321.

DP2 Write a PL/SQL code to accept emp_id from user and display his / her record.

Table: Employee (EmpId, EName, DOJ, DOB, Salary, Address)

DP3 Write a PL/SQL code to calculate the area of a 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 Areas, consisting of two columns Radius and Area.

Table: Circle (Radius, Area, Circumference)

DP4 Write a PL/SQL code that first withdraws an amount of Rs. 1500 from an account.

Then deposits an amount of Rs. 50,000 in another account. Update the current balance.

Then check to see that the sum of the current balance of all the accounts in the bank

Page 19: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-165; Database Management Systems Lab. | Version 1.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi Page 19 of 23

does not exceed Rs. 60,00,000. If the balance exceeds Rs 60,00,000 then undo the deposit

just made.

Table : Accounts(AcCNo, Name, Balance, DateofOpening, DateofLastTransaction)

DP5 Write a PL/SQL code that accepts the account number from the user, check the users

balance and updates date of last transaction. If it is greater than 1000, only then

deduct Rs. 200/- from the balance, otherwise rollback the date of transaction to set it

to the previous date. The process is fired on the Acct_Mstr table.

Table : Acct_Mstr(AcCNo, Name, Balance, DateofOpening, DateofLastTransaction)

Advanced Problems:

DA1 Write a PL/SQL code that gives 5% hike in basic salary to all employees. Then

calculate the total sum of all salaries. If total salary is more than a fixed budget

(inputted by user), rollback the entire updation.

Table : Employee(EmpId, EName, DOJ, DOB, Salary, Address)

DA2 Write a PL/SQL code that accepts roll number of a student from user, fetch his/her

marks of three subjects in from the table, calculate his percentage and upate the same

in the table.

Table : Stduent(RollNo, SName, DOB, Sub1, Sub2, Sub3, Total, Percenatge, Grade)

DA3 Write a PL/SQL code that calculates factorial of first five even numbers and stores the

same in the given table.

Table : Factorial (No, Fact)

Assignment Set: E

Objectives of the Assignment:

• To use implicit and explicit cursors for accessing multiple records from tables.

• To work with exception handling in PL/SQL programs.

CO/BTLCovered: CO3 & CO4/ BTL3

Problems:

EP1 The bank manager of Delhi branch decides to mark the status of all those accounts as

‘Inactive’ on which there are no transactions performed in last 6 months. Whenever

any such update takes place the corresponding record is inserted in another table

Page 20: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-156; Database Management Systems Lab. | Version 10.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi | Page 20 of 23

‘InactiveAccounts’ with the name and account no of the account holder and his

balance.

Table : Account (AccNo, Name, Address, PANNo, Mobile, Status)

EP2 Write a PL/SQL code that updates the balance of the account holder of ‘Delhi’ branch

and displays the number of records updated. (Use implicit cursor)

Table : Accounts(AcCNo, Name, Balance, DateofOpening, Branch)

EP3 Write a Cursor( PL/SQL code) to display the Employee_name, DateofBirth,

Designation whose basic salary is greater than 15000, if not found then show the

proper error message. (Use Exception handing)

Table : Employee(EmpId, EName, DOJ, DOB, Salary, Address)

EP4 Write a Cursor( PL/SQL code) to display the Book_Name, Author and Price of those

books that belong to ‘TMH’ publisher. If no record found then show the proper error

message. (Use Exception handing)

Table : Book(ISBN_No, BName, Publicaher, Author, Price)

Advanced Problems:

EA1 Write a PL/SQL code that updates the marks of all those students who are fail and

then counts the number of records updated. (Use implicit cursor)

Table : Stduent(RollNo, SName, DOB, Sub1, Sub2, Sub3, Total, Percenatge, Grade)

EA2 Write a PL/SQL code that accepts the train no, source and destination from the user,

finds the recods of the train in the given table. Display the record if record found

otherwise display an appropriate message.

Table : Train (TrainNo, Name, Source, Destination, NoOfStops, NoOfCoaches)

Assignment Set: F

Objectives of the Assignment:

• To use the features of procedures and functions.

CO/BTLCovered: CO3/ BTL3

Problems:

FP1 Create a procedure that accepts the emp id from the calling procedure and displays

Page 21: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-165; Database Management Systems Lab. | Version 1.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi Page 21 of 23

his/her record.

Table : Employee(EmpId, EName, DOJ, DOB, Salary, Address)

FP2 Create a function that accepts emp id from the calling procedure and returns his

salary.

Table : Employee(EmpId, EName, DOJ, DOB, Salary, Address)

FP3 Write a PL/SQL function ODDEVEN to return value TRUE if the number passed to it

is EVEN else will return FALSE.

FP4 Write a PL/SQL procedure called MULTI_TABLE that takes two numbers as

parameter and displays the multiplication of the first parameter till the second

parameter.

Advanced Problems:

FA1 Create a procedure that accepts the roll no from the calling procedure and fetch his

marks of three subjects from the given table to calculate his percentage.

FA2 Create a function that accepts book id from the calling procedure, finds if it is a ‘TMH’

publication. If ‘yes’ then return its price.

FA3 Write a PL/SQL function ‘Prime’ to return true value if the number is prime else

return false.

FA4 Write a PL/SQL procedure that accepts two numbers from a user and returns the

larger number as INOUT parameters.

Assignment Set: G

Objectives of the Assignment:

• To develop triggers for some events such as insert, delete or update.

• To learn, use and differentiate before and after triggers.

CO/BTLCovered: CO3/ BTL3

Problems:

GP1 Create a Trigger in PL/SQL which will work before deletion or updation in

employee_master table and inserts a duplicate copy of the record in another table for

future reference.

Table : Employee_Master(EmpId, EName, DOJ, DOB, Salary, Address)

Page 22: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-156; Database Management Systems Lab. | Version 10.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi | Page 22 of 23

Emp_Backup (EmpId, EName, DOJ, DOB, Salary, DateofOperation)

GP2 Create a Trigger in P L/SQL which will work after update or insert on employee

_master and store the old data and deleted data in a table named as

backup_employee_master.

Table: Employee_Master(EmpId, EName, DOJ, DOB, Salary, Address)

Backup_employee_master (EmpId, EName, DOJ, DOB, Salary, DateofOperation)

Advanced Problems:

GA1 Given Student Report table, in which student marks assessment is recorded. In such

schema, create a trigger so that the total and average of specified marks is automatically

inserted whenever a record is insert.

Table : Stduent(RollNo, SName, DOB, Sub1, Sub2, Sub3, Total, Average, Grade)

GA2 To create a row level trigger for the CUSTOMERS table that would fire for INSERT or

UPDATE or DELETE operations performed on the CUSTOMERS table. The trigger

should display the difference in amount paid between the old values and new values.

Table: Customer (CustId, Cname, Address, OrderNo, AmountPaid, DateofPayment)

APPENDIX

Template for the Index of Lab File

WEEK

NO.

PROBLEMS WITH DESCRPTION PAGE

NO.

SIGNATURE

OF THE

TEACHER

WITH DATE

1 AP1

AP2

AP3

2 AA1

AA2

AA3

Page 23: Database Management Systems Lab Lab Manual.pdfand its record need to be maintained in the Prcatical File, having prescribed format, as given in Appendix-A. All the students should

Laboratory Manual for MCA-165; Database Management Systems Lab. | Version 1.0

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi Page 23 of 23

3 BP1

BP2

BP3

BP4

Note: The students should use Header and Footer mentioning their roll no. & name in

header and page no. in footer

**********