You are on page 1of 193

ACROPOLIS INSTITUTE OF TECHNOLOGY AND RESEARCH

Department of Computer Science and Engineering


Course File
Subject Name: Database Management Systems Subject Code: CS502
Faculty Name: Narendra Pal Singh Rathore Session: July Dec 2021
Program: B.Tech. (CSE) Semester: 5th
Contents
A. Vision, Mission, PEO, PO and PSO
1. Vision and Mission of the Institute
2. Vision and Mission of the Department
3. Program Educational Objectives (PEO), Program Outcomes (PO), and Program Specific
Outcomes (PSO)
B. Curriculum and Teaching–Learning
1. University Scheme and Syllabus
2. Course Educational Objectives(CEO) and Course Outcomes (CO)
3. CO-PO-PSO Mapping and Justification
4. Subject Time Table
5. Lecture Plan
6. Innovative Teaching Methods Used
7. Curricular Gaps Identified and Action Taken
8. Record of Lectures / Tutorials
9. Record of Remedial / Extra Classes
10. Record of Practical Classes
11. Previous Years’ University Question Papers
12. Question Bank
13. Interview / Viva FAQ
14. Notes and Presentations
15. Lab Manual
C. Assessment Tools and Attainment
1. Assessment Tools and Weightage
2. Assignment and Tutorial Sheets
3. Quiz/ Unit Test/ Class Test
4. Mid Semester Test Papers
5. Practical List
6. Schedule of Different Assessments
D. Student Performance
1. Attendance Record
2. Student Evaluation Sheet
3. University Results
4. List of Slow & Fast Learner and Action Taken
E. Continuous Improvement
1. Previous Semester Feedback
2. Recommendations Based on Observations
A. Vision, Mission, PEO, PO and PSO
1. Vision and Mission of the Institute

Vision
To be an academic leader for the development of human potential so as to meet the global challenges.

Mission of the Institute


a. To create an intellectually stimulating learning environment.
b. To impart value based, innovative, and research oriented education.
c. To develop positive attitude with communication skills.
d. To increase employability and entrepreneurship through collaboration with industries and
professional organizations.

2. Vision and Mission of CSE Department

Vision
The department strives to produce competent and qualified computer professionals and researchers to
serve the community and profession with moral values and ethics.

Mission of CSE Department


a. To impart professional education emphasizing intellectual ability creation.
b. To provide learning ambience for enhancing innovations, research, and values among the students.
c. To collaborate with industries for giving opportunities to students to develop their employability
and entrepreneurship skills.
d. To inculcate professional behavior, positive attitude, and communication skills.

3. Program Educational Objectives (PEOs), Program Outcomes (POs), and Program


Specific Outcomes (PSOs)

Program Education Objectives-

PEO1: Preparation
Graduates will be prepared for successful technical career, higher studies, research and development
and will be able to take up the challenges for innovations, idea generation, and values.

PEO2: Professionalism
Graduates will work as an individual as well as a team on multi-disciplinary projects with effective
communication skills and positive attitude.

PEO3: Lifelong learning


Graduates will have good communication skill and social concerns to meet the challenges of national
and multi-national companies.
Program Outcomes (PO)
a. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and
an engineering specialization to the solution of complex engineering problems.
b. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and
engineering sciences.
c. Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the
public health and safety, and the cultural, societal, and environmental considerations.
d. Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information to
provide valid conclusions.
e. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
understanding of the limitations.
f. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional
engineering practice.
g. Environment and sustainability: Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.
h. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the
engineering practice.
i. Individual and team work: Function effectively as an individual, and as a member or leader in diverse
teams, and in multidisciplinary settings.
j. Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and
design documentation, make effective presentations, and give and receive clear instructions.
k. Project management and finance: Demonstrate knowledge and understanding of the engineering and
management principles and apply these to one’s own work, as a member and leader in a team, to
manage projects and in multidisciplinary environments.
l. Life-long learning: Recognize the need for and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.

Program Specific Outcomes (PSOs) of CSE Department


Engineering Graduates will be able to:

PSO1: Make use of modern languages and tools such as HTML5, CSS, MongoDB, IOS, IOT, Android,
Hadoop; Work on newer computing paradigms such as Cloud Computing, Big Data ; Acquire globally
accepted certification in latest technologies such as Google Applied CS with Android, HTML5, MongoDB,
Big Data, SQL, Data analytics.
PSO2: Apply standard Software Engineering practices and strategies in software project development.
Learn making use of open source libraries in software development.

PSO3: Emphasize on solution oriented approach by problem identification, analysis and design of
computer based system for solving the problems of different complexities.

B. Curriculum and Teaching Learning:


1. University Scheme and Syllabus:

Scheme:
Contact
Practical
Theory Marks Hours per
Marks
week
Subject Name
Subject Code

Mid Semester Exam

Quiz / Assignment
Category

Term
End Semester

End Semester

Total Credits
Total Marks
Work /
Lab L T P
Work &
Sessional

Data Base
CS502 DC 70 20 10 30 20 150 3 - 2 4
Management System

University Syllabus, Recommended Course Objective, Course Outcome, Books, and


Practical List by University:

DBMS Concepts and architecture Introduction, Database approach v/s Traditional file accessing
approach, Advantages, of database systems, Data models, Schemas and instances, Data independence,
Data Base Language and interfaces, Overall Database Structure, Functions of DBA and designer, ER data
model: Entitles and attributes, Entity types, Defining the E-R diagram, Concept of Generalization,
Aggregation and Specialization. transforming ER diagram into the tables. Various other data models
object oriented data Model, Network data model, and Relational data model, Comparison between the
three types of models.

Relational Data models: Domains, Tuples, Attributes, Relations, Characteristics of relations, Keys, Key
attributes of relation, Relational database, Schemas, Integrity constraints. Referential integrity, Intension
and Extension, Relational Query languages: SQL-DDL, DML, integrity constraints, Complex queries,
various joins, indexing, triggers, assertions, Relational algebra and relational calculus, Relational algebra
operations like select, Project, Join, Division, outer union. Types of relational calculus i.e., Tuple oriented
and domain oriented relational calculus and its operations.

Data Base Design: Introduction to normalization, Normal forms, Functional dependency, Decomposition,
Dependency preservation and lossless join, problems with null valued and dangling tuples, multivalued
dependencies. Query Optimization: Introduction, steps of optimization, various algorithms to implement
select, project and join operations of relational algebra, optimization methods: heuristic based, cost
estimation based.

Transaction Processing Concepts: -Transaction System, Testing of Serializability, Serializability of


schedules, conflict & view serializable schedule, recoverability, Recovery from transaction failures. Log
based recovery. Checkpoints deadlock handling. Concurrency Control Techniques: Concurrency Control,
locking Techniques for concurrency control, time stamping protocols for concurrency control, validation
based protocol, multiple-granularity. Multi version schemes, Recovery with concurrent transaction.
Introduction to Distributed databases, data mining, data warehousing, Object Technology and DBMS,
Comparative study of OODBMS Vs DBMS . Temporal, Deductive, Multimedia, Web & Mobile database.

Study of Relational Database Management Systems through Oracle/PL SQL QL/MySQL: Architecture,
physical files, memory structures, background process. Concept of table spaces, segments, extents and
block. Dedicated server, multi-threaded server. Distributed database, database links, and snapshot. Data
dictionary, dynamic performance view. Security, role management, privilege management, profiles,
invoker defined security model. SQL queries, Data extraction from single, multiple tables equi- join, non
equi-join, self -join, outer join. Usage of like, any, all, exists, in Special operators. Hierarchical quires,
inline queries, flashback queries. Introduction of ANSI SQL, anonymous block, nested anonymous block,
branching and looping constructs in ANSI SQL. Cursor management: nested and parameterized cursors,
Oracle exception handling mechanism. Stored procedures, in, out, in out type parameters, usage of
parameters in procedures. User defined functions their limitations. Triggers, mutating errors, instead of
triggers.

RGPV References:
1. Date C J, “An Introduction To DatabaseSystem”, Pearson Educations
2. Korth, Silbertz,Sudarshan, “Fundamental of Database System”, McGraw Hill
3. Rob, “ Data Base System:Design Implementation & Management”, Cengage Learninig
4. Elmasri, Navathe, “Fundamentals of Database Systems”, Pearson Educations
5 . Atul Kahate , “ Introduction to Database Management System”, Pearson Educations
6. Oracle 9i Database Administration Fundamental-I, Volume I, Oracle Press,TMH.
7. Paneerselvam,”DataBase Management System”, PHI Learning
8. dev.mysql.com
9. www.postgressql.org

List of Experiments(Expandable):
1. Delete duplicate row from the table.
2. Display the alternate row from table.
3. Delete alternate row from table.
4. Update multiple rows in using single update statement.
5. Find the third highest paid and third lowest paid salary.
6. Display the 3rd, 4th, 9th rows from table.
7. Display the ename, which is start with j, k, l or m.
8. Show all employees who were hired the first half of the month.
9. Display the three records in the first row and two records in the second row and one record in the
third row in a single sql statements.
10. Write a sql statements for rollback commit and save points.
11. Write a pl/sql for select, insert, update and delete statements.
12. Write a pl/sql block to delete a record. If delete operation is successful return 1 else return 0.
13. Display name, hire date of all employees using cursors.
14. Display details of first 5 highly paid employees using cursors.
15. Write a database trigger which fires if you try to insert, update, or delete after 7’o’ clock.
16. Write a data base trigger, which acts just like primary key and does not allow duplicate values.
17. Create a data base trigger, which performs the action of the on delete cascade.
18. Write a data base trigger, which should not delete from emp table if the day is Sunday.
19. In this subject the students are supposed to prepare a small database application in complete
semester like financial accounting system, Railway reservation system, institute timetable management
system. Student record system, library management system, hospital management system etc. in
RDBMS as follows:
Section A: Solving the case studies using ER data model (design of the database)
Section B: Implement a mini project for the problem taken in section A.

2. Course Educational Objectives (CEO) and Course Outcomes (CO):

Course Educational Objectives


CEO1 To understand fundamental knowledge of file system, database concepts and
use of relational database.
CEO2 To study of different data model and conceptual design using ER diagram.

CEO3 Students able to learn SQL operations to manipulate the database and able to
optimize query.
CEO4 To understand the process and characteristics to design and create a good
database using functional dependencies and normalization.
CEO5 To understand the overview of transaction management, concurrency control,
distributed database and Big Data.

Course Outcomes
Upon completion of this subject / course the student will be able:

CO1 Compare file system and DBMS and explain how DBMS is better than
traditional File Processing Systems.

CO2 Analyze the physical and logical database designs, database modeling,
relational, hierarchical, and network models.

CO3 Analyze and renovate an information model into a relational database schema
and to use a DDL, DML and DCL utilities to implement the schema using a
DBMS.
CO4 Formulate data retrieval queries in SQL and Relational Algebra. Demonstrate an
understanding of functional dependencies, normalization theory and apply
such knowledge to the design of a database.
CO5 Demonstrate and explain terms like Transaction Processing, Concurrency
Control, distributed database and big data. Evaluate a business situation and
designing & building a database applications
3. CO-PO-PSO Mapping and Justification:
PO PSO

PO10

PO11

PO12

PSO1

PSO2

PSO3
PO1

PO2

PO3

PO4

PO5

PO6

PO7

PO8

PO9
Course Outcomes

CO1 2 1 1 1 1 0 0 0 0 0 0 1 1 0 1

CO2 2 1 1 1 1 0 0 0 0 0 0 0 1 0 1

CO3 2 2 1 1 0 0 0 0 0 0 0 0 1 0 1

CO4 3 1 1 0 1 0 0 0 0 0 0 0 1 0 1

CO5 2 2 0 1 1 0 0 0 0 0 0 1 1 0 1

Justifications

Mapping Justification for Mapping LOW(1) MEDIUM(2) HIGH(3)


CO1-PO1 MEDIUM(2) As students could just understand and classify different data models.
Students could identify functionalities of DBMS. Knowledge in
CO1-PO2,3,4,5,12 LOW(1) architecture of DBMS help students to clearly understand the
functionalities of DBMS.
Students will be able to understand the formulation and
CO2-PO1 MEDIUM (2)
working of SQL queries.
Students gain knowledge in E-R modelling Students acquire
CO2-PO2,3,4,5 LOW(1) competency in building E-R models of databases. Student can apply
the design knowledge to implement the industry projects.
Students acquire competency in developing SQL queries to interact
CO3-PO1,2 MEDIUM (2) with databases. Students will be able to identify oracle database
structure.
Students will gain knowledge in classifying different normal forms.
CO3-PO3,4 LOW(1) Students gain competency in designing databases following normal
form standards.
Students acquire and apply knowledge in transaction processing and
CO4-PO1 HIGH(3) related issues, concurrency control, query processing and
optimization.
Students gain competency in understanding different query
CO4-PO2,3,5 LOW(1)
processing & optimization.
Understanding of the database system models for database design to
CO5-PO1,2 MEDIUM (2) evaluate a business situation and designing & building a database
application.
CO5-PO4,5 LOW(1) Students acquire competency in developing PL/SQL programs.
Students gain competency in understanding database, SQL and
different query processing & optimization approaches to evaluate
CO1,2,3,4,5-PSO1 LOW(1)
and apply the knowledge to design and implement in database
application.
Students acquire competency in database designing, data
CO1,2,3,4,5-PSO3 LOW(1)
organization, normalization and developing PL/SQL programs.
4. Subject Time-Table:

Prof. Kavita Namdev

8.20- 9.05- 9.50- 10:30- 11.20- 12.10- 1.00- 1.50 - 2.40- 3.30- 4.15-
DAY
9.05 9.50 10.30 11:20 12.10 1.00 1.50 2.40 3.30 4.15 5.00
/
TIME I II III IV V VI VII VII IX X XI
MON DBMS
DBMS
TUE DBMS
(P)
WED
THUR DBMS
FRI DBMS

SAT

Prof. Kavita Namdev

8.20- 9.05- 9.50- 10:30- 11.20- 12.10- 1.00- 1.50 - 2.40- 3.30- 4.15-
DAY
9.05 9.50 10.30 11:20 12.10 1.00 1.50 2.40 3.30 4.15 5.00
/
TIME I II III IV V VI VII VII IX X XI
DBMS
MON DBMS
(P)
TUE DBMS
WED
THUR DBMS

FRI DBMS

SAT

Prof. Rahul Patel

8.20- 9.05- 9.50- 10:30- 11.20- 12.10- 1.00- 1.50 - 2.40- 3.30- 4.15-
DAY
9.05 9.50 10.30 11:20 12.10 1.00 1.50 2.40 3.30 4.15 5.00
/
TIME I II III IV V VI VII VII IX X XI
MON DBMS
TUE
WED DBMS
THUR DBMS

FRI DBMS DBMS(P)


SAT
Prof. Narendra Pal Singh Rathore

8.20- 9.05- 9.50- 10:30- 11.20- 12.10- 1.00- 1.50 - 2.40- 3.30- 4.15-
DAY
9.05 9.50 10.30 11:20 12.10 1.00 1.50 2.40 3.30 4.15 5.00
/
TIME I II III IV V VI VII VII IX X XI
MON DBMS
TUE DBMS DBMS(P)
WED DBMS
THUR
FRI DBMS

SAT

5. Lecture Plan with Details of Reference Material and Prerequisite:


Sr.
Objective Content Example
No.

 What is Data Item or Fields,


 Understand what Databases. Records, Files, Database? Student, Employee,
1  Components of Database.  Data item, Relationships, Railway, Doctor’s,
 Identify the scope and necessity Constraints and Schema. University, Databases.
of Database.  Internal schema, Conceptual
schema and External schema.
Types of Files

 Master Files
 Transaction Files
 Master File: Student
Understand the Types of file and  Record Files Files Organization. database.
2
File Organization.  Heap File Organization.  Transaction File: Price
 Sequential File Organization. of the products
 Indexed-Sequential File
Organization.
 Direct File Organization.
 Advantages of learning File Oriented Oracle, DB2, Sybase,
3 Understand the Need of DBMS. System. Informix, Ms-SQL server
 Disadvantages of learning File etc.
Oriented System.
 Introduction to DBMS and
architecture.
 Functions and Responsibilities of
DBAs.

4 Database approach v/s Traditional  Advantages of DBMS.


file.
 Disadvantages of DBMS.
 DDL and DML.
5 Understand Database Languages.  SDL and VDL. SQL
 Fourth Generation Language (4GL).
 Schema defined using Database
Language.
 Internal Level  Railway reservation and
6 Understand the concept of Three  Conceptual Level
Level ANSI-SPARC Architecture.  External Level Student Information
 Advantages of Three tier System
Architecture.
7  Physical data independence.
Understand Data Independence.
 Logical data independence.
 Mappings.
 Record Based data models
a) Hierarchical data models.
b) Network data models.
c) Relational data models.
 Object-based data models.  Country->State->City-
8 Understand Basic Concepts of Data
a) Entity-Relationship >Street->Building-
Models. b) Semantic
c) Functional >Room
d) Object-Oriented
 Physical data models.
a) Unifying Model
b) Frame memory model
 Entitles and attributes.
 Employee
 Entity types, defining the E-R
9 diagram.  Student
Understand ER data model.
 Concept of Generalization,
 University
Aggregation and Specialization
 Transforming ER diagram into the  Bank Account
tables.
 Domains, Tuples, Attributes,
10 Implementation of Relational Data Relations.  Stu_id
Models.  Characteristics of relations
 Emp_ID
 Keys, Key attributes of relation.
 Relational database.
11  Domain Constraints  Check
Understand Integrity Constraints
 Referential Integrity.
 Foreign Key
 Dangling Tuples.
12  Need of SQL.
Introduce the structured query
 What is SQL?
language (SQL).  Features of SQL.
 Rules for SQL.
 Components of SQL: DDL, DML, DCL ,
DQL
 Create Command, Insert, and Delete.
13 Understand the DDL, DML, DQL Employee Database
 Alter, Drop, Truncate.
and DCL Commands.
 Truncate, Grant, Revoke.
 Commit, Rollback. Save point, Select
 Primary key constraints
 Feature of Primary Keys  Stu_id
14 Understand Data Constraints and
 Foreign key constraints  Bal>500
Types of Data Constraints.
 Features of Foreign Keys
 Unique key constraints  Scholar no unique
 Business Rule constraints.
15  Sub queries.
Understand Complex queries
 Joins
 Syntax of Group By, Exist, Joins.
16  Need of Relational Algebra. Use Student Database
Relational Algebra
 Set theoretic operations
 Native Relational Operations
 UNION.
17 Implementations of Set theoretic
 Intersection
and Native Relational Operations.
 Difference, Product and Projection.
 Selection Join and Divison.
18 Aggregate Functions and Rename  SUM, Deletion, Calligraphic G Total Salary
Operation.  Insertion.
 Updating.
 Need of Views.
Required only student
 Understand Views.  Declaration of Views.
19  Relational Calculus.  Types of Views. marks details not whole
 Tuple Relational Calculus. information.
 Domain Relational Calculus.
 Well Formed Formula (WFF).
20 Introduction to Normalization.  Need of Normalization.
 Normal Forms.
 First normal form (1NF)
 Second normal form (2NF) Un-normalized Database:
21 Types of Normal Forms.  Third normal form (3NF)
Student
 Boyce/Codd normal form (BCNF).
 Fourth normal form (4NF).
 Fifth normal form (5NF).
 Introduction First normal form and Partial and Transitive
its problem.
22 Understand First, Second and Third Dependencies in Student
 Introduction Second normal form
Normal Form and its problem. database
 Introduction Third normal form and
its problem.
 Introduction BCNF and its problem Solution of Prime
23 Understand Boyce-codd normal
 Introduction Multi valued Attribute
form (BCNF) and Multi valued
Dependencies.
Dependencies.

24 Understand 4NF and Join  Introduction Fourth normal form and


dependencies. its problem.
 Introduction to join dependencies.
25  Introduction Fifth normal form  Functional Dependency diagram and
 Introduction to Functional Examples.
Dependency (FD).  Full Functional Dependency (FFD).
 Rule 1-Reflexivity (Inclusion), Rule 2-
Augmentation, Rule 3-Transitivity.
 Rule 4-Self-determination, Rule 5-
26 Understand Armstrong’s Axioms
Pseudo transitivity, Rule 6-Union or
for Functional Dependencies. additive.
 Rule 7 –Decomposition or Projective,
Rule 8- Composition, Rule 9-Self
accumulation.
 Introduction to Decomposition.
27  Lossy Decomposition. Product and Qty
Understand Decomposition.
 Lossless-join Decomposition.
 Dependency-Preserving
Decomposition.
28 Understand Query Optimization.  Primary goal of query optimizer.
 Query Simplifier.
29 Algorithms for implementing
 Algorithm for SELECT and JOIN
operations. operations.

30 Algorithms for implementing


 Algorithm for PROJECT and SET
operations. operations
31 Understand Optimization methods.  Heuristic query optimization.
 Cost estimation based.
 Transaction concepts
32 Understand Transaction processing  Bill Payment
 Serializability
systems.
 Read only Transaction.  Net Banking
 Transaction Boundaries
Understand Database Access
33  Read item Balance Enquiry
Operations and Consistent state of
 Write item
database  Begin Transaction.
 Begin Transaction.
34 Transaction execution and  Read/Write. Banking Transaction
problems.  END Transaction.
 Commit-Transaction,
 Rollback (or Abort).
 Why Recovery is needed.
 Computer failure.
35  Understand concept of Recovery.  A Transaction or System error and
Failed Payment and
 Types of failure and Transaction local error.
deduct amount
Properties.  Concurrency control enforcement
and Disk failure.
 Physical Problem and ACID property.
 Journals.
36  Concept of Transaction log Reservation system
 Write-ahead log strategy.
 Understand the concept of
 Last updates.
Concurrency and its problems.
 Dirty Read and Unrepeated read.
37 Understand Schedule and  Scheduler.
Serializable Schedule  Serial and non-serial schedule
 Complete schedule
 Conflict and View Serializability.
 Conflict and Non Serializable. Banking system update
38 Understand Types of Serializability
 View equivalent and blind writes. and retrieval
 Testing for Conflict Serializability
(Precedence Graph).
 What is Lock? S locks or Read lock
39  Concurrency Control and Lock  X lock or exclusive lock Movie ticket booking
Granularity.  Granule and Lock table, lock
 Types of Locks manager and levels of locking.
 Binary, Exclusive and shared locking.
 Two-phase locking
 Three phase locking  Traffic Signal System
40 Types of Locks and Deadlock.  Strict 2 phase locking.  Traffic Signal System
 Deadlock Situation, detection and
preventions. with Traffic police
 Wait for graph
 Introduction to Timestamps, Basic
Timestamps.
 Strict Timestamps and Thomson
Write Rule.
41  Understand Timestamp method
 Database Recovery Concepts and
and Validation/Optimistic.
Database Backup.
 Database Recovery System
 Physical Damage and Non-physical or
Transaction Failure.
 Immediate update, Shadow paging
and Checkpoints.
 Distributed databases and Data
42 Understand the Advanced concepts mining.
 Data warehousing, Object
Technology and DBMS.
 Introduction to Oracle 10g.
Study of Relational Database
43  Architecture, physical files, memory
Management Systems through
structures, background process.
Oracle 10g.  Dedicated server, multi-threaded
server
 Introduction of ANSI SQL,
44 anonymous block, nested
Understand the Concept of PL/SQL.
anonymous block.
 Branching and looping constructs in
ANSI SQL.
 Nested and parameterized cursors.
45 Understand the Cursor
 User defined functions their
management PL/SQL. limitations
 Triggers
 Oracle exception handling
mechanism
 Stored procedures

Text/Reference Books:

Text Book Elmasri, Navathe, “Fundamentals of Database Systems”, Pearson


Educations.
Reference Book  Korth, Silbertz, Sudarshan, “Fundamental of Database System”, McGraw
Hill.
 Lecture Notes “Prof P Sreenivasa Kumar Department of CS&E, IITM”.
 S.K.Singh “Database Systems”, Pearson Educations.
 Oracle 10g Database Administration Fundamental-I, Volume I, Oracle
Press, TMH
Recommended Book and Elmasri, Navathe, “Fundamentals of Database Systems”, Pearson
Reference Material Educations.
Websites / Online  https://onlinecourses.nptel.ac.in/noc18_cs15/preview.
Tutorials  https://www.coursera.org/learn/database-management.
 http://codex.cs.yale.edu/avi/db-book/db6/slide-dir/index.html.
Other Learning Resources Like computer based programs / CD, Professional Standards/ Regulations
/ Ethics
NPTEL Video Library https://nptel.ac.in/courses/106105175
NPTEL Certification https://onlinecourses.nptel.ac.in/noc21_cs04/preview
Course
Virtual Lab / Spoken http://vlabs.iitb.ac.in/bootcamp/labs/dbms/exp8/index.php
Tutorial
Other MOOC https://www.coursera.org/learn/database-management.

Prerequisite(s) (if any):


a. Knowledge of Programming Data Structure and Algorithms.

6. Innovative Teaching Methods Used:


a. In assignment students has submitted online published articles on well recognized platforms.
b. Quiz using Quizizz.com
c. E-Learning courses provided

7. Curricular Gaps Identified and Action Taken


Measures and processes used to identify the curricular gaps to the attainment of the COs/POs (Tick the
applicable process)

1. Student’s feedback.
2. Outgoing Student’s feedback.
3. Employer’s feedback.
4. Alumni feedback.
5. Feedback from placement team.
6. Faculty experience of the concerned subject.
7. Comparison with curriculum of Institute of repute(like IITs and NITs).
Topics covered beyond the syllabus {if any, as per gaps}:

SNo Gap(Topic beyond Syllabus) Action Taken DD/ Resource No. of


MM Person with Students
/YY Designation
01 PL/ SQL https://www.youtub - - -
e.com/watch?v=J5wjI
f4gdq4
02 Index - - -
https://academy.orac
le.com/en/oa-web-
overview.html

8. Record of Lectures/Tutorial Held:


Class Section CS1
Lec.
No Unit CO Date Topic Covered in Lecture Attd.
No
Introduction to the subject and OBE. Data Item or Fields,
1 I CO1 02-Aug-21 1 51
Records, Files, Database, Relationships, Constraints.
Schema: Internal schema, Conceptual schema, and
2 I CO1 03-Aug-21 2 49
External schema. Instances.
Types of Files: Master Files, Transaction Files, Record
Files, Files Organization: Heap File Organization,
3 I CO1 04-Aug-21 3 53
Sequential File Organization. Indexed-Sequential File
Organization. Direct File Organization.
Advantages and Disadvantages of learning File Oriented
4 I CO1 05-Aug-21 4 46
System.
5 I CO1 06-Aug-21 Introduction to DBMS and architecture. 5 49
Functions and Responsibilities of DBAs. Advantages and
6 I CO1 09-Aug-21 6 52
Disadvantages of DBMS.
7 I CO1 10-Aug-21 Database Languages: DDL, DML, SDL and VDL. 7 50
8 I CO1 11-Aug-21 Three level architecture and its advantages. 8 58
9 I CO1 12-Aug-21 Data Independence and Mappings. 9 54
Record Based data models: Hierarchical data models,
10 I CO1 13-Aug-21 10 54
Network data models,
11 I CO1 14-Aug-21 Relational data models. 11 56
12 I CO1 16-Aug-21 Object-based data models: Entity-Relationship, 12 66
Semantic, Functional, Object-Oriented. Physical data
13 I CO1 17-Aug-21 13 62
models: Unifying Model, Frame memory model.
14 II CO2 18-Aug-21 ER data model: Entities, 14 68
15 II CO2 19-Aug-21 Attributes and its types. 15 63
16 II CO2 23-Aug-21 Entity types, 16 68
17 II CO2 24-Aug-21 Keys 17 68
18 II CO2 25-Aug-21 Defining the E-R diagram. 18 64
Concept of Generalization, Aggregation and
19 II CO2 31-Aug-21 19 65
Specialization
20 II CO2 01-Sep-21 Transforming ER diagram into the tables. 20 67
21 II CO2 03-Sep-21 Relational Data Models: Domain, Tuples, Relations 21 63
22 II CO2 06-Sep-21 Characteristics of relations. Relational database. 22 67
23 II CO2 07-Sep-21 Domain Constraints, Referential Integrity, Dangling 23 62
Tuples.
24 III CO3 08-Sep-21 SQL: Introduction, features, need and its components. 24 66
25 III CO3 13-Sep-21 DDL and DML statements with example. 25 60
26 III CO3 13-Sep-21 DQL and DCL statements with example. 26 64
27 III CO3 14-Sep-21 Data Constraints and Types of Data Constraints. 27 64
28 III CO3 15-Sep-21 Sub queries, Joins and Exist keyword. 28 62
Relational Algebra and its importance. Set theoretic
29 III CO3 17-Sep-21 29 61
operations
Native Relation Operation. Aggregate function and
30 III CO3 20-Sep-21 30 62
Rename operation.
31 III CO3 21-Sep-21 Primary goal of query optimizer. Query Simplifier. 31 62
32 III CO3 22-Sep-21 Algorithm for SELECT and JOIN operations. 32 76
33 III CO3 24-Sep-21 Algorithm for PROJECT and SET operations. 33 66
34 III CO3 25-Sep-21 Heuristic query optimization. Cost estimation based. 34 62
Functional Dependency and Fully functional
35 IV CO3 27-Sep-21 35 60
dependency.
36 IV CO4 28-Sep-21 Armstrong Axioms 36 62
37 IV CO4 29-Sep-21 Functional Dependency diagram and Examples. 37 59
38 IV CO4 01-Oct-21 Closure of FD and example 38 56
39 IV CO4 04-Oct-21 Irreducible Set of FD’s. 39 56
40 IV CO4 05-Oct-21 Decomposition and its types. 40 64
41 IV CO4 06-Oct-21 Normalization and its importance 41 64
42 IV CO4 12-Oct-21 Types of Normalizations and its problem. 42 61
43 IV CO4 13-Oct-21 Exercise question on Normal form identification. 43 58
44 V CO5 18-Oct-21 Transaction processing systems. 44 56
45 V CO5 19-Oct-21 Database Access Operations. 45 57
46 V CO5 20-Oct-21 Transaction execution and problems. 46 53
47 V CO5 22-Oct-21 Concept of Recovery and its need. 47 53
Types of Transaction failure and ACID Property of
48 V CO5 25-Oct-21 48 55
Transaction.
Transaction log and concept of concurrency in
49 V CO5 26-Oct-21 49 54
transactions.
50 V CO5 27-Oct-21 Concurrency problems in transactions. 50 53
51 V CO5 08-Nov-21 Schedule and Serializability 51 48
52 V CO5 09-Nov-21 Types of Serializability and examples. 52 44
53 V CO5 10-Nov-21 Concurrency control and locking 53 56
54 V CO5 12-Nov-21 Types of locking with example. 54 49
55 V CO5 23-Nov-21 Timestamp methods. Advanced concept of Databases. 55 41
Introduction of PL/SQL and Cursor Management in
56 V CO5 24-Nov-21 56 47
PL\SQL.
Class Section CS2
Lec.
No Unit CO Date Topic Covered in Lecture Attd.
No
Introduction to the subject and OBE. Data Item or Fields,
1 I CO1 02-Aug-21 1 50
Records, Files, Database, Relationships, Constraints.
Schema: Internal schema, Conceptual schema, and
2 I CO1 03-Aug-21 2 55
External schema. Instances.
Types of Files: Master Files, Transaction Files, Record
Files, Files Organization: Heap File Organization,
3 I CO1 04-Aug-21 3 47
Sequential File Organization. Indexed-Sequential File
Organization. Direct File Organization.
Advantages and Disadvantages of learning File Oriented
4 I CO1 05-Aug-21 4 57
System.
5 I CO1 06-Aug-21 Introduction to DBMS and architecture. 5 51
Functions and Responsibilities of DBAs. Advantages and
6 I CO1 09-Aug-21 6 55
Disadvantages of DBMS.
7 I CO1 10-Aug-21 Database Languages: DDL, DML, SDL and VDL. 7 62
8 I CO1 11-Aug-21 Three level architecture and its advantages. 8 60
9 I CO1 12-Aug-21 Data Independence and Mappings. 9 61
Record Based data models: Hierarchical data models,
10 I CO1 13-Aug-21 10 61
Network data models,
11 I CO1 17-Aug-21 Relational data models. 11 62
12 I CO1 19-Aug-21 Object-based data models: Entity-Relationship, 12 61
Semantic, Functional, Object-Oriented. Physical data
13 I CO1 20-Aug-21 13 67
models: Unifying Model, Frame memory model.
14 II CO2 23-Aug-21 ER data model: Entities, 14 66
15 II CO2 24-Aug-21 Attributes and its types. 15 70
16 II CO2 26-Aug-21 Entity types, 16 70
17 II CO2 27-Aug-21 Keys 17 64
18 II CO2 31-Aug-21 Defining the E-R diagram. 18 65
Concept of Generalization, Aggregation and
19 II CO2 02-Sep-21 19 64
Specialization
20 II CO2 03-Sep-21 Transforming ER diagram into the tables. 20 64
21 II CO2 07-Sep-21 Relational Data Models: Domain, Tuples, Relations 21 64
22 II CO2 09-Sep-21 Characteristics of relations. Relational database. 22 64
Domain Constraints, Referential Integrity, Dangling
23 II CO2 13-Sep-21 23 61
Tuples.
24 III CO3 14-Sep-21 SQL: Introduction, features, need and its components. 24 70
25 III CO3 15-Sep-21 DDL and DML statements with example. 25 68
26 III CO3 17-Sep-22 DQL and DCL statements with example. 26 66
27 III CO3 24-Sep-21 Data Constraints and Types of Data Constraints. 27 68
28 III CO3 25-Sep-21 Sub queries, Joins and Exist keyword. 28 71
Relational Algebra and its importance. Set theoretic
29 III CO3 27-Sep-21 29 71
operations
Native Relation Operation. Aggregate function and
30 III CO3 28-Sep-21 30 69
Rename operation.
31 III CO3 29-Sep-21 Primary goal of query optimizer. Query Simplifier. 31 67
32 III CO3 01-Oct-21 Algorithm for SELECT and JOIN operations. 32 68
33 III CO3 04-Oct-21 Algorithm for PROJECT and SET operations. 33 65
34 III CO3 05-Oct-21 Heuristic query optimization. Cost estimation based. 34 69
35 IV CO3 05-Oct-21 Functional Dependency and Fully functional 35 59
dependency.
36 IV CO4 06-Oct-21 Armstrong Axioms 36 63
37 IV CO4 06-Oct-21 Functional Dependency diagram and Examples. 37 61
38 IV CO4 12-Oct-21 Closure of FD and example 38 65
39 IV CO4 12-Oct-21 Irreducible Set of FD’s. 39 63
40 IV CO4 13-Oct-21 Decomposition and its types. 40 60
41 IV CO4 13-Oct-21 Normalization and its importance 41 60
42 IV CO4 18-Oct-21 Types of Normalizations and its problem. 42 61
43 IV CO4 18-Oct-21 Exercise question on Normal form identification. 43 49
44 V CO5 19-Oct-21 Transaction processing systems. 44 57
45 V CO5 19-Oct-21 Database Access Operations. 45 57
46 V CO5 20-Oct-21 Transaction execution and problems. 46 50
47 V CO5 22-Oct-21 Concept of Recovery and its need. 47 44
Types of Transaction failure and ACID Property of
48 V CO5 25-Oct-21 48 55
Transaction.
Transaction log and concept of concurrency in
49 V CO5 26-Oct-21 49 54
transactions.
50 V CO5 27-Oct-21 Concurrency problems in transactions. 50 53
51 V CO5 08-Nov-21 Schedule and Serializability 51 48
52 V CO5 09-Nov-21 Types of Serializability and examples. 52 44
53 V CO5 10-Nov-21 Concurrency control and locking 53 56
54 V CO5 12-Nov-21 Types of locking with example. 54 49
55 V CO5 23-Nov-21 Timestamp methods. Advanced concept of Databases. 55 41
Introduction of PL/SQL and Cursor Management in
56 V CO5 24-Nov-21 56 47
PL\SQL.

Class Section CS3


Lec.
No Unit CO Date Topic Covered in Lecture Attd.
No
Introduction to the subject and OBE. Data Item or Fields,
1 I CO1 02-Aug-21 1 49
Records, Files, Database, Relationships, Constraints.
Schema: Internal schema, Conceptual schema, and
2 I CO1 03-Aug-21 2 53
External schema. Instances.
Types of Files: Master Files, Transaction Files, Record
Files, Files Organization: Heap File Organization,
3 I CO1 04-Aug-21 3 49
Sequential File Organization. Indexed-Sequential File
Organization. Direct File Organization.
Advantages and Disadvantages of learning File Oriented
4 I CO1 04-Aug-21 4 56
System.
5 I CO1 05-Aug-21 Introduction to DBMS and architecture. 5 51
Functions and Responsibilities of DBAs. Advantages and
6 I CO1 6-Aug-21 6 54
Disadvantages of DBMS.
7 I CO1 09-Aug-21 Database Languages: DDL, DML, SDL and VDL. 7 60
8 I CO1 10-Aug-21 Three level architecture and its advantages. 8 60
9 I CO1 11-Aug-21 Data Independence and Mappings. 9 62
Record Based data models: Hierarchical data models,
10 I CO1 12-Aug-21 10 59
Network data models,
11 I CO1 13-Aug-21 Relational data models. 11 62
12 I CO1 16-Aug-21 Object-based data models: Entity-Relationship, 12 62
Semantic, Functional, Object-Oriented. Physical data
13 I CO1 17-Aug-21 13 64
models: Unifying Model, Frame memory model.
14 II CO2 19-Aug-21 ER data model: Entities, 14 65
15 II CO2 20-Aug-21 Attributes and its types. 15 67
16 II CO2 23-Aug-21 Entity types, 16 68
17 II CO2 24-Aug-21 Keys 17 62
18 II CO2 26-Aug-21 Defining the E-R diagram. 18 64
Concept of Generalization, Aggregation and
19 II CO2 27-Aug-21 19 64
Specialization
20 II CO2 13-Sep-21 Transforming ER diagram into the tables. 20 62
21 II CO2 14-Sep-21 Relational Data Models: Domain, Tuples, Relations 21 62
22 II CO2 16-Sep-17 Characteristics of relations. Relational database. 22 62
Domain Constraints, Referential Integrity, Dangling
23 II CO2 20-Sep-21 23 62
Tuples.
24 III CO3 21-Sep-21 SQL: Introduction, features, need and its components. 24 66
25 III CO3 23-Sep-21 DDL and DML statements with example. 25 65
26 III CO3 24-Sep-21 DQL and DCL statements with example. 26 66
27 III CO3 25-Sep-21 Data Constraints and Types of Data Constraints. 27 67
28 III CO3 27-Sep-21 Sub queries, Joins and Exist keyword. 28 68
Relational Algebra and its importance. Set theoretic
29 III CO3 28-Sep-21 29 70
operations
Native Relation Operation. Aggregate function and
30 III CO3 29-Sep-21 30 67
Rename operation.
31 III CO3 30-Sep-21 Primary goal of query optimizer. Query Simplifier. 31 66
32 III CO3 01-Oct-21 Algorithm for SELECT and JOIN operations. 32 67
33 III CO3 04-Oct-21 Algorithm for PROJECT and SET operations. 33 66
34 III CO3 05-Oct-21 Heuristic query optimization. Cost estimation based. 34 68
Functional Dependency and Fully functional
35 IV CO3 06-Oct-21 35 63
dependency.
36 IV CO4 07-Oct-21 Armstrong Axioms 36 63
37 IV CO4 19-Oct-21 Functional Dependency diagram and Examples. 37 52
38 IV CO4 20-Oct-21 Closure of FD and example 38 52
39 IV CO4 21-Oct-21 Irreducible Set of FD’s. 39 54
40 IV CO4 22-Oct-21 Decomposition and its types. 40 54
41 IV CO4 25-Oct-21 Normalization and its importance 41 58
42 IV CO4 26-Oct-21 Types of Normalizations and its problem. 42 58
43 IV CO4 27-Oct-21 Exercise question on Normal form identification. 43 54
44 V CO5 28-Oct-21 Transaction processing systems. 44 51
45 V CO5 08-Nov-21 Database Access Operations. 45 49
46 V CO5 08-Nov-21 Transaction execution and problems. 46 47
47 V CO5 08-Nov-21 Concept of Recovery and its need. 47 43
Types of Transaction failure and ACID Property of
48 V CO5 9-Nov-21 48 47
Transaction.
Transaction log and concept of concurrency in
49 V CO5 10-Nov-21 49 44
transactions.
50 V CO5 11-Nov-21 Concurrency problems in transactions. 50 48
51 V CO5 12-Nov-21 Schedule and Serializability 51 41
52 V CO5 15-Nov-21 Types of Serializability and examples. 52 39
53 V CO5 15-Nov-21 Concurrency control and locking 53 41
54 V CO5 16-Nov-21 Types of locking with example. 54 34
55 V CO5 22-Nov-21 Timestamp methods. Advanced concept of Databases. 55 36
56 V CO5 23-Nov-21 Introduction of Cursor Management in PL/SQL 56 41
Class Section CS4
Lec.
No Unit CO Date Topic Covered in Lecture Attd.
No
Introduction to the subject and OBE. Data Item or Fields,
1 I CO1 02-Aug-21 1 44
Records, Files, Database, Relationships, Constraints.
Schema: Internal schema, Conceptual schema, and
2 I CO1 03-Aug-21 2 48
External schema. Instances.
Types of Files: Master Files, Transaction Files, Record
Files, Files Organization: Heap File Organization,
3 I CO1 04-Aug-21 3 39
Sequential File Organization. Indexed-Sequential File
Organization. Direct File Organization.
Advantages and Disadvantages of learning File Oriented
4 I CO1 05-Aug-21 4 43
System.
5 I CO1 06-Aug-21 Introduction to DBMS and architecture. 5 41
Functions and Responsibilities of DBAs. Advantages and
6 I CO1 09-Aug-21 6 35
Disadvantages of DBMS.
7 I CO1 10-Aug-21 Database Languages: DDL, DML, SDL and VDL. 7 48
8 I CO1 11-Aug-21 Three level architecture and its advantages. 8 51
9 I CO1 12-Aug-21 Data Independence and Mappings. 9 50
Record Based data models: Hierarchical data models,
10 I CO1 13-Aug-21 10 46
Network data models,
11 I CO1 16-Aug-21 Relational data models. 11 45
12 I CO1 18-Aug-21 Object-based data models: Entity-Relationship, 12 54
Semantic, Functional, Object-Oriented. Physical data
13 I CO1 19-Aug-21 13 61
models: Unifying Model, Frame memory model.
14 II CO2 20-Aug-21 ER data model: Entities, 14 60
15 II CO2 23-Aug-21 Attributes and its types. 15 69
16 II CO2 25-Aug-21 Entity types, 16 60
17 II CO2 27-Aug-21 Keys 17 64
18 II CO2 01-Sep-21 Defining the E-R diagram. 18 63
Concept of Generalization, Aggregation and
19 II CO2 02-Sep-21 19 61
Specialization
20 II CO2 03-Sep-21 Transforming ER diagram into the tables. 20 61
21 II CO2 06-Sep-21 Relational Data Models: Domain, Tuples, Relations 21 67
22 II CO2 08-Sep-21 Characteristics of relations. Relational database. 22 65
Domain Constraints, Referential Integrity, Dangling
23 II CO2 09-Sep-21 23 69
Tuples.
24 III CO3 13-Sep-21 SQL: Introduction, features, need and its components. 24 70
25 III CO3 15-Sep-21 DDL and DML statements with example. 25 71
26 III CO3 16-Sep-21 DQL and DCL statements with example. 26 69
27 III CO3 17-Sep-21 Data Constraints and Types of Data Constraints. 27 69
28 III CO3 20-Sep-21 Sub queries, Joins and Exist keyword. 28 70
Relational Algebra and its importance. Set theoretic
29 III CO3 24-Sep-21 29 68
operations
Native Relation Operation. Aggregate function and
30 III CO3 27-Sep-21 30 66
Rename operation.
31 III CO3 29-Sep-21 Primary goal of query optimizer. Query Simplifier. 31 64
32 III CO3 30-Sep-21 Algorithm for SELECT and JOIN operations. 32 65
33 III CO3 01-Oct-21 Algorithm for PROJECT and SET operations. 33 62
34 III CO3 04-Oct-21 Heuristic query optimization. Cost estimation based. 34 67
35 IV CO3 06-Oct-21 Functional Dependency and Fully functional 35 68
dependency.
36 IV CO4 07-Oct-21 Armstrong Axioms 36 68
37 IV CO4 13-Oct-21 Functional Dependency diagram and Examples. 37 68
38 IV CO4 14-Oct-21 Closure of FD and example 38 64
39 IV CO4 18-Oct-21 Irreducible Set of FD’s. 39 65
40 IV CO4 20-Oct-21 Decomposition and its types. 40 63
41 IV CO4 21-Oct-21 Normalization and its importance 41 62
42 IV CO4 22-Oct-21 Types of Normalizations and its problem. 42 65
43 IV CO4 25-Oct-21 Exercise question on Normal form identification. 43 64
44 V CO5 27-Oct-21 Transaction processing systems. 44 57
45 V CO5 28-Oct-21 Database Access Operations. 45 61
46 V CO5 29-Oct-21 Transaction execution and problems. 46 57
47 V CO5 08-Nov-21 Concept of Recovery and its need. 47 54
Types of Transaction failure and ACID Property of
48 V CO5 10-Nov-21 48 64
Transaction.
Transaction log and concept of concurrency in
49 V CO5 11-Nov-21 49 51
transactions.
50 V CO5 12-Nov-21 Concurrency problems in transactions. 50 51
51 V CO5 15-Nov-21 Schedule and Serializability 51 54
52 V CO5 17-Nov-21 Types of Serializability and examples. 52 52
53 V CO5 18-Nov-21 Concurrency control and locking 53 56
54 V CO5 19-Nov-21 Types of locking with example. 54 52
55 V CO5 22-Nov-21 Timestamp methods. Advanced concept of Databases. 55 47
Introduction of PL/SQL and Cursor Management in
56 V CO5 24-Nov-21 56 44
PL\SQL.

9. Record of Remedial Classes / Extra Classes


Lecture
No Date Topic Covered Reason for Class Attendance
Number
01 24-Sep-21 E-R Diagram Concepts Project Implementation 3 64
02 11-Nov-21 Normalization of the Tables Project Implementation 2 63

10. Record of Practical Classes:


SNo Title Practical Date Remarks
B1 B2 B3
01 SQL Introduction and DDL Queries. 03-Aug-21
02 DML and Data Retrieval 10-Aug-21
03 Advance Data Retrieval 17-Aug-21
04 Sub, Correlated, Nested and Set Queries 24-Aug-21
05 Queries on Join 31-Aug-21
06 Views, Synonyms, Indexes and Sequences 07-Sep-21
07 TCL and DCL Statements 14-Sep-21
08 PL/SQL Implementation 21-Sep-21
09 Cursors 28-Sep-21
10 Procedure and Functions 05-Oct-21
11 Triggers 19-Oct-21
12 Project Table implementation 09-Nov-21

11. Previous Years’ University Question Papers:


rgpvonline.com
rgpvonline.com
CS - 503
B.E. V Semester
Examination, December 2014
Database Management System
Time : Three Hours
Maximum Marks : 70
Note: i) Answer five questions. In each question part A, B, C is compulsory and D part has
internal choice.
ii) All parts of each question are to be attempted at one place.
iii)All questions carry equal marks, out of which part A and B (Max.50 words) carry 2 marks, part
C (Max.1 00 words) carry 3 marks, part D (Max.400 words) carry 7 marks.
iv) Except numericals, Derivation, Design and Drawing etc.
Unit-I
1. a) How is the data-based approach different from the file based approach?
b) Differentiate the term data, information and knowledge.
c) What is schema and subschema? Explain these two concepts through examples.
d) What are the problem caused by data redundancies? Can data redundancy be completely
eliminated when a database approach is used.
OR
Define the concept of aggregation. Give several examples of where this concept is useful.
Unit-II
2. a) What is aggregate functions of SQL?
b) What is the difference between procedural DML and non procedural DML?
c) Explain the characteristics of relation. Also explain the relational databases.
d) What are integrity constraints? Define the term primary key constraint and foreign key
constraint. How are these constraints expressed in SQL?
OR
Explain the Join operator, its relevance and its various types.
Unit-III
3. a) Discuss how dangling tuple may arise?
b) What is query optimization?
c) What is join dependency? How is it different to that of Multivalued dependency and
Functional dependency?
d) "Redundancy is the back bone of reliability, therefore, a reliable database system should not
attempt normalization beyond 3NF". Comment on the above statement. Give reason in support of or
against the above statement.
OR
What is Normalization? Explain second normal form with the help of an example.
Unit-IV
4. a) What is web databases?
b) Define the concept of Data warehousing.
c) What is a schedule? What is an interleaved schedule? How is schedule related to the term
serializability?
d) Explain the advantages and disadvantages of distributed database.
OR
What is time stamping? Explain a mechanism of concurrency control that uses time stamping
with the help of an examples.
Unit-V
5 a) Define segment, extents and block,
b) What is Flashback queries? Where it is used?
c) Explain the advantage of stored procedures.
d) What is PL/SQL exception handling and why it is needed? Also explain user defined exception
and system. Defined Exceptions.
OR
Explain the following:
i) Implicit and Explicit cursors
ii) Dedicated and multi threaded server
HTTP://WWW.RGPVONLINE.COM
Total No. of Questions : 8] [1] [Total No. of Printed Pages : 4

Roll No ..................................

CS-502-CBGS
B.Tech., V Semester
Examination, December 2020
Choice Based Grading System (CBGS)
Database Management Systems
Time : Three Hours
Maximum Marks : 70
Note: i) Attempt any five questions.
{H$Ýht nm±M àíZm| H$mo hb H$s{OE&
ii) All questions carry equal marks.
g^r àíZm| Ho$ g_mZ A§H$ h¢&
iii) All parts of each questions to be are attempted at one place.
à˶oH$ àíZ Ho$ g^r ^mJm| H$mo EH$ hr ñWmZ ‘| hb H$s{OE&
iv) In case of any doubt or dispute the English version
question should be treated as final.
{H$gr ^r àH$ma Ho$ g§Xoh AWdm {ddmX H$s pñW{V ‘| A§J«oOr ^mfm
Ho$ àíZ H$mo A§{V‘ ‘mZm Om¶oJm&
1. a) How is precedence graph made to check serializability?
7
H«$‘Ur¶Vm H$mo Om±MZo Ho$ {bE àYmZVm J«m’$ H¡$go ~Zm¶m OmVm h¢?
b) Explain Fragmentation and its types in detail. 7
{dI§S>Z Ed§ CgHo$ àH$mam| H$m {dñVma go C„oI H$s{OE&
2. a) What do you mean by deadlock handling? How can we
resolve deadlock? 7
S>oS>bm°H$ h¢¡S>qbJ go Amn ³¶m g‘PVo h¢? S>oS>bm°H$ H$mo H¡$go hb
H$aVo h¢?
CS-502-CBGS PTO

https://www.rgpvonline.com
[2]

b) Differentiate physical level and logical level of data


abstraction. 7
S>mQ>m E~ñQ´>o³eZ Ho$ {’${OH$b bodb Ed§ Vm{H©$H$ bodb ‘| AÝVa
ñnï> H$a|&

3. a) What is two phase locking (2PL)? Describe with the help


of an example. 7
{Û MaUr¶ bm±qH$J ³¶m h¢? C{MV CXmhaU XoH$a g‘PmBE&
b) What is Log? How is it maintained? 7
A{^boI ³¶m h¢? BZH$m AZwajU H¡$go {H$¶m OmVm h¢?

4. a) Discuss the role of database administrator. 7


S>oQ>m~og à~§YH$ H$s ^y{‘H$m na {dñVma go MMm© H$s{OE&
b) Consider a relation R with five attribute A, B, C, D, E having
following dependencies : A → B, BC → E and ED → A
7
i) List all keys for R
ii) In which normal form table is
Xr JB© [aboeZ R Ho$ nm±M EQ´>rã¶yQ²>g A, B, C, D, E H$s {S>n|S>|grO
Bg àH$ma h¢ A → B, BC → E Ed§ ED → A .
i) [aboeZ R H$s g^r "H$s' H$mo {b{IE&
ii) gmaUr {H$g Zm°‘©b ’$m°‘© h¢ {b{IE&

5. a) Explain specialization and generalization feature of ER


diagram with example. 7
B.Ama. {MÌ Ho$ gm‘mݶrH$aU Ed§ {d{eï>rH$aU H$s {deofVm H$mo
CXmhaU g{hV g‘PmBE&
CS-502-CBGS Contd...
PTO

https://www.rgpvonline.com
[3]

b) What is lossless decomposition in database? How it is


useful in database? 7
hm{Z‘wº$ {d¶moOZ ³¶m h¢ S>oQ>m~og ‘|? ¶h S>oQ>m~og Ho$ {bE H¡$go
Cn¶moJr h¢?
6. a) List out the operations that can be performed on files. 7
’$mBb Ho$ D$na {H$¶o OmZo dmbo Am°naoeZm| H$s gyMr {dñVma go
{b{IE&
b) Explain the concept of query optimization. 7
³doar Am°pßQ>‘mBOoeZ H$s g§H$ënZm H$mo g‘PmBE&
7. a) Explain the following commands with syntax. 7
i) Select
ii) Update
iii) Delete
{ZåZ{b{IV {ZX}em| H$mo qgQ>o³g g{hV g‘PmBE&
i) {gbo³Q>
ii) AnS>Qo >
iii) {S>brQ>
b) Differentiate DML, DDL and DCL in detail. 7
S>r E‘ Eb, S>r S>r Eb Ed§ S>r gr Eb ‘| AÝVa ñnîQ> H$s{OE&
8. Write short note on any three of the following : 14
i) Concurrency control
ii) Multivalued dependency
iii) Hashing technique
iv) Join dependency
v) Various keys in DBMS

CS-502-CBGS PTO

https://www.rgpvonline.com
[4]

{ZåZ ‘| go {H$Ýht VrZ na g§{já {Q>ßnUr {b{IE&


i) g§Jm{‘{V {Z¶§ÌU
ii) ~hþ‘mZ {Z^©aVm
iii) h¡qeJ VH$ZrH$
iv) ÁdmBZ {Z^©aVm
v) S>r ~r E‘ Eg ‘| {d{^Þ ‘H$s’

******

CS-502-CBGS PTO

https://www.rgpvonline.com
https://www.rgpvonline.com

Total No. of Questions : 8] [1] [Total No. of Printed Pages : 2

Roll No ..................................
CS-5003-CBGS
B.E. V Semester
Examination, June 2020
Choice Based Grading System (CBGS)
Data Base Management System
Time : Three Hours
Maximum Marks : 70
Note: i) Attempt any five questions.
ii) All questions carry equal marks.

1. a) Explain Super key, primary key, candidate key with


examples.
b) Develop an ER diagram for library management.

2. a) What is the significance of using the views? Write a


command to create the view.
b) Explain strong and weak entities. How weak entity can be
converted to a strong entity.

3. a) What are integrity constraints? Explain various types of


integrity constraints with suitable example.
b) Explain Relational algebra with taking a suitable example.

4. a) Compute Canonical Cover Fc for the


R = {A, B, C, D} and FD’s = {ABC,
BC, AB, ABC, ACD}
b) What is redundancy? What are the problem caused by the
redundancy?

CS-5003-CBGS PTO

https://www.rgpvonline.com
https://www.rgpvonline.com

[2]

5. a) Explain serializability in transaction management.


b) How concurrency is performed? Explain the protocol that
is used to maintain the concurrency concept.

6. What is distributed database system? How it is different from


the centralized database system? Give the use of distributed
system.

7. What is Cursor Management? Explain nested and parameterized


cursors.

8. Write a short notes (any three):


i) Triggers
ii) Normalization
iii) Multimedia
iv) SQL

******

CS-5003-CBGS PTO

https://www.rgpvonline.com
12.Question Bank
Sr.
Question BL
No.
1 Define the terms data and information? REMEMBEING
2 Define (i) Database (ii)DBMS REMEMBEING
3 List the advantages and applications of DBMS? REMEMBEING
4 What are the disadvantages of file processing system? REMEMBEING
5 Define instances and schemas of database? REMEMBEING
6 What is data model? List the types of data models? REMEMBEING
7 Discuss about Data Definition language? CREATING
8 Discuss about Data Manipulation language? CREATING
9 What is data Abstraction? Give the levels of data abstraction? REMEMBEING
10 Who is DBA? What are the responsibilities of DBA? REMEMBEING
11 Discuss Data Independence? C CREATING
12 What is an entity relationship model? REMEMBEING
13 Define (i) Entity (ii) Attribute REMEMBEING
14 Define Relationship and relationship set. REMEMBEING
15 What are key constraint and participating constraints? REMEMBEING
16 Define weak entity and strong entity sets? REMEMBEING
17 Define relation, relation instance and relation schema. REMEMBEING
18 Define i) super key ii)candidate key iii) primary key REMEMBEING
19 Explain the use of foreign key constraint? UNDRESTANDING
20 Define the terms arity and cardinality of relation? REMEMBEING
21 What are domain constraints REMEMBEING
22 Explain about querying relational data? UNRESTANDING
23 Define views? REMEMBEING
24 Discuss how can you change the data in the table? CREATING
25 List various types of attributes? REMEMBEING
26 Discuss how can you alter and destroy tables? CREATING
27 Explain the use of null values? UNRESTANDING
28 Define relational database query? REMEMBERING
29 Explain different types of query languages? UNDRESTANDING
30 Explain about relational algebra? UNDRESTANDING
31 State about SELECT operation in Relational algebra. ANALYZE
32 State about PROJECT operation in Relational algebra? ANALYZE
33 Explain about set operations? UNDRESTANDING
34 Discuss the use of rename operation? CREATING
35 Define join ? Explain different join operations? REMEMBERING
36 Compare and Contrast file Systems with database system? UNDRESTANDING
37 Define Data Abstraction and discuss levels of Abstraction? REMEMBERING
38 Discuss about different types of Data models? CREATING
39 Describe the architecture of DBMS? CREATING
40 Discuss additional features of the ER-Models? CREATING
41 Discuss about the Conceptual Design with the ER-Model? CREATING
42 Write about views and updates on views? REMEMBERING
43 Explain different types of database users and write the functions of DBA? UNDRESTANDING
44 Explain about different types of integrity constraints? UNDRESTANDING
45 Discuss about the logical database Design? CREATING
Distinguish strong entity set with weak entity set? Draw an ER diagram to
46 UNDRESTANDING
illustrate Weak entity set?
47 Explain how the integrity constraints are specified and enforces? UNDRESTANDING
48 Explain in detail about views? UNDRESTANDING
49 Illustrate redundancy and the problems that it can cause UNDRESTANDING
Define decomposition and how does it address redundancy? Discuss the
50 REMEMBERING
problems that may be caused by the use of decompositions?
51 Define functional dependencies. How are primary keys related to FD‘s? REMEMBERING
52 Define normalization? Explain 1NF,2NF,3NF normal forms REMEMBERING
53 Compare and contrast BCNF with 3NF? UNDRESTANDING
54 Describe properties of decompositions CREATING
55 Explain ACID properties and illustrate them through examples? UNDRESTANDING
56 Discuss How do you implement Atomicity and Durability CREATING
57 Illustrate Concurrent execution of transaction with examples. UNDRESTANDING
58 Discuss Serializability in detail? CREATING
Discuss two phase locking protocol and strict two phase locking
59 CREATING
protocols?
60 Describe Times tamp based locking protocols? CREATING
61 Describe Validation-based locking protocols? CREATING
62 Discuss in detail Multiple Granularity? CREATING
63 Explain in detail storage structure. UNDRESTANDING
64 Discuss how do you recover from failure? CREATING
65 Explain Buffer Management? UNDRESTANDING
66 Explain different types of advanced recovery techniques UNDRESTANDING
67 Write in detail about Remote Backup systems? REMEMBERING
68 Write in detail about hash based indexing and Tree based indexing REMEMBERING
69 Compare I/O costs for all file organizations UNDRESTANDING
70 Explain in detail about ISAM. UNDRESTANDING
71 Explain about B+ tree index file? UNDRESTANDING
Demonstrate searching a given element in B+ trees? Explain with
72 UNDRESTANDING
example?
73 Illustrate insertion of an element in B+ Tree with example UNDRESTANDING
74 Illustrate deletion of an element in B+ Tree with example UNDRESTANDING
75 Write in detail about Static Hashing . UNDRESTANDING
76 Explain in detail about Extendible hashing . UNDRESTANDING
77 Explain in detail about Linear hashing. UNDRESTANDING
78 Compare and contrast Extendible hashing With Linear hashing UNDRESTANDING
79 Describe how the insert and delete operations are performed in B+ tree? CREATING
80 Explain Clustered Indexes? UNDRESTANDING

13.Interview / Viva FAQ


Unit 1
1. Define database management system?
2. List any eight applications of DBMS.
3. What are the disadvantages of file processing system?
4. What are the advantages of using a DBMS?
5. Give the levels of data abstraction?
6. Define instance and schema?
7. Define the terms 1) physical schema 2) logical schema.
8. What is conceptual schema?
9. Define data model?
10. What is storage manager?
11. What are the components of storage manager?
12. What is the purpose of storage manager?
13. List the data structures implemented by the storage manager.
14. What is a data dictionary?
Unit 2
1. What is an entity relationship model?
2. What are attributes? Give examples.
3. What is relationship? Give examples
4. Define the terms Entity Set.
5. Define single valued and multivalued attributes.
6. What are stored and derived attributes?
7. What are composite attributes?
8. Define null values.
9. Define the terms relationship set
10. What is meant by the degree of relationship set?
11. Define the term Entity.
12. Define weak and strong entity sets?
13. What does the cardinality ratio specify?
14. Explain the two types of participation constraint.
15. Define the terms data model.
16. Write short notes on relational model
17. Define tuple and attribute.
18. Define the term relation.
19. Define tuple variable
20. Define the term Domain.
21. What is a candidate key?
22. What is a primary key?
23. What is a super key?
24. Define- relational algebra.
25. What is a SELECT operation?
26. What is a PROJECT operation?
27. Write short notes on tuple relational calculus.
28. Write short notes on domain relational calculus
29. Define query language?
30. Write short notes on Schema diagram.
31. What is foreign key?
UNIT: 3
1. What are the parts of SQL language?
2. What are the categories of SQL command?
3. What are the three classes of SQL expression?
4 Give the general form of SQL query?
5. What is the use of rename operation?
6. Define tuple variable?
7. List the string operations supported by SQL?
8. List the set operations of SQL?
9. What is the use of Union and intersection operation?
10. What are aggregate functions? And list the aggregate functions supported by SQL?
11. What is the use of group by clause?
12. What is the use of sub queries?
13. What is view in SQL? How is it defined?
14. What is the use of with clause in SQL?
15. List the table modification commands in SQL?
16. List out the statements associated with a database transaction?
17. What is transaction?
18. List the SQL domain Types?
19. What is the use of integrity constraints?
20. Mention the 2 forms of integrity constraints in ER model?
21. What is trigger?
22. What are domain constraints?
23. What are referential integrity constraints?
24. What is assertion? Mention the forms available.
25. Give the syntax of assertion?
26. What is the need for triggers?
27. List the requirements needed to design a trigger.
28. Give the forms of triggers?
29. What does database security refer to?
30. List some security violations (or) name any forms of malicious access.
31. List the types of authorization.
32. What is authorization graph?
33. List out various user authorization to modify the database schema.
34. What are audit trails?
35. Mention the various levels in security measures.
36. Name the various privileges in SQL?
37. Mention the various user privileges.
38. Give the limitations of SQL authorization.
to ensure the absence of loopholes.
39. Give some encryption techniques?
40. What does authentication refer?
41. List some authentication techniques.
Unit 4:
1. Define Boyce CODD normal form
2. List the disadvantages of relational database system
3. What is first normal form?
4. What is meant by functional dependencies?
5. What are the uses of functional dependencies?
6. Explain trivial dependency?
7. What are axioms?
8. What is meant by computing the closure of a set of functional dependency?
9. What is meant by normalization of data?
10. Define canonical cover?
11. List the properties of canonical cover.
12. Explain the desirable properties of decomposition.
13. What is 2NF?
14. What is an index?
15. Define query optimization.
16. Define access time.
17. Define seek time.
18. Define average seek time.
19. Define rotational latency time.
20. Define average latency time.
21. What is meant by data-transfer rate?
22. What is meant by mean time to failure?
23. What are a block and a block number?
24. What are called journaling file systems?
25. What is the use of RAID?
26. What is called mirroring?
27. What is called mean time to repair?
28. What is called bit-level striping?
30. What are the two main goals of parallelism?
31. What are the factors to be taken into account when choosing a RAID level?
32. What is meant by software and hardware RAID systems?
33. Define hot swapping?
34. What are the ways in which the variable-length records arise in database systems?
35. What is the use of a slotted-page structure.
36. What are the two types of blocks in the fixed –length representation? Define them.
37. What is known as heap file organization?
38. What is known as sequential file organization?
39. What is hashing file organization?
40. What is known as clustering file organization?
41. What are the types of indices?
42. What are the techniques to be evaluated for both ordered indexing and hashing?
43. What is known as a search key?
44. What is a primary index?
45. What are called index-sequential files?
46. What are the two types of indices?
47. What are called multilevel indices?
48. What is B-Tree?
49. What is a B+-Tree index?
50. What is a hash index?
51. What is called query processing?
52. What are the steps involved in query processing?
53. What is called an evaluation primitive?
54. What is called a query evaluation plan?
55. What is called a query –execution engine?
56. What are called as index scans?
57. What is called as external sorting?
58. What is called as recursive partitioning?
59. What is called as an N-way merge?
60. What is known as fudge factor?
UNIT: 5
1. What is transaction?
2. What are the two statements regarding transaction?
3. What are the properties of transaction?
4. What is recovery management component?
5. When is a transaction rolled back?
6. What are the states of transaction?
7. What is a shadow copy scheme?
8. Give the reasons for allowing concurrency?
9. What is average response time?
10. What are the two types of Serializability?
11. Define lock?
12. What are the different modes of lock?
13. Define deadlock?
14. Define the phases of two-phase locking protocol
15. Define upgrade and downgrade?
16. What is a database graph?
17. What are the two methods for dealing deadlock problem?
18. What is a recovery scheme?
19. What are the two types of errors?
20. What are the storage types?
21. Define blocks?
22. What is meant by Physical blocks?
23. What is meant by buffer blocks?
24. What is meant by disk buffer?
25. What is meant by log-based recovery?
26. What are uncommitted modifications?
27. Define shadow paging.
28. Define page.
29. Explain current page table and shadow page table.
30. What are the drawbacks of shadow-paging technique?
31. Define garbage collection.
32. Differentiate strict two-phase locking protocol and rigorous two-phase locking protocol.
33. How the time stamps are implemented
34. What is the time stamps associated with each data item?

14. Class Notes & Presentation of Lectures


5/25/2022

Lecture -1 Overview of
Subject
By: Narendra Pal Singh Rathore
www.acropolis.in

1 2

Topics to be covered Data


Data Scheme Raw & Isolated facts that can be recorded.
Information Reference Books Text, Number are traditional data
Database Online Courses Image, Video, Audio, Map are multimedia data

Why Database Google Classroom Details Data play a very vital role in digital word.
Job Roles Planning Now days before business flow required data.
Course Objective Q/A We read reviews before
Purchasing any item from amazon, flipkart.
Course Outcomes
Movie Watch
Syllabus
After Jio the name of new yug is Data Yug.
25 May 2022 narendrasingh@acropolis.in 3 25 May 2022 narendrasingh@acropolis.in 4

3 4

Information Relation Between Data & Information


Processed, meaningful, usable data on which decision or action are
based.
Organized & classified data to provide meaningful values.
Information is always based on observer / reader.
Example: Teacher gives the assignment to students.

25 May 2022 narendrasingh@acropolis.in 5 25 May 2022 narendrasingh@acropolis.in 6

5 6

1
5/25/2022

Is it
Information
Data vs Information Data vs Information ??

10121992 Now 10/12/1992 is the DOB of Kunal Singh S/o Bairav Singh.
Now 10/12/1992 is the DOB of Kunal Singh S/o Bairav Singh leave in
10/12/1992 Date 44 telephone nagar, Indore, MP, India, 452018.
Still confused it is data or information ?? Now we can say we have information of Kunal Singh DOB.
10/12/1992 DOB Is it information ??? It does not matter information is available in text, image, audio,
Is it video or any other format.
Still, You are unable to derive complete information.
Information
??
Now 10/12/1992 is the DOB of Kunal Singh.

Img src: https://pixabay.com/vectors/detective-searching-man-search-1424831/

25 May 2022 narendrasingh@acropolis.in 7 25 May 2022 narendrasingh@acropolis.in 8

7 8

Data vs Information Need to relate data

Information
Employee Doctor’s Book’s
Product’s Data Data
Data
Data

Data Information

Student Sales Project’s Faculty


Data Data Data Data

Information

25 May 2022 narendrasingh@acropolis.in 9 25 May 2022 narendrasingh@acropolis.in 10

9 10

Database Database
It is the collection of similar / related data.
Employee Doctor’s
Sales
For better deriving the information to solve the problems.
Book’s Data Data
Data
Data Its not depend on the data format means it may be stored in any
format.
Faculty
Data Example Data Database
Project’s Product’s
Data Data Songs Soundcloud
Student
Data Video YouTube
Image Instagram
Text / number Acropolis ERP system
Coordinates / Map Google Map
25 May 2022 narendrasingh@acropolis.in 11 25 May 2022 narendrasingh@acropolis.in 12

11 12

2
5/25/2022

Example of Database Tools / Software to Manage Databases = DBMS


College Database: Organize data of Student, admin staff, faculty.
Library Database: Books, Magazines
Hospital Database: Doctors, patient
Railway System Database: Trains, Stations, Drivers.
Employee Database: Employee data, salary, tax deduction
Airlines Database: Airline's data, route, reservation data
Hotel Database: Rooms data, services data
Sales Database: Product, purchase, customer data
Img Src: https://www.learncomputerscienceonline.com/database-management-system/

25 May 2022 narendrasingh@acropolis.in 13 25 May 2022 narendrasingh@acropolis.in 14

13 14

Database Management System Job Roles based on DBMS


Database Management System ( DBMS ) is a software application Data Analyst : average salary $60,187 per year
used to create , manage and administer the databases. Database Developer : average salary $98,415 per year
A DBMS is integral and necessary part of almost all modern Database Administrator : average salary $94,406 per year.
organizations irrespective of the size and scale of the business Data Scientist : average salary $135,000 per year
operations. SQL Server Developer : average salary $102,400 per year
Software Developer : average salary $102,528 per year
Software Consultant : average salary $ 118,000 per year
ETL Developer : average salary $107,250 per year
Big Data engineer : average salary $ 136,500 per year
25 May 2022 narendrasingh@acropolis.in 15 25 May 2022 narendrasingh@acropolis.in 16

15 16

Vision Mission of CSE Department


The department strives to produce competent and qualified To impart professional education emphasizing intellectual ability
computer professionals and researchers to serve the community and creation.
profession with moral values and ethics. To provide learning ambience for enhancing innovations, research,
and values among the students.
To collaborate with industries for giving opportunities to students to
develop their employability and entrepreneurship skills.
To inculcate professional behavior, positive attitude, and
communication skills.

25 May 2022 narendrasingh@acropolis.in 17 25 May 2022 narendrasingh@acropolis.in 18

17 18

3
5/25/2022

Course Objectives Course Outcomes


To understand fundamental knowledge of file system, database Understand the different issues involved in the design and
concepts and use of relational database. implementation of a database system.
To study of different data model and conceptual design using ER Study the physical and logical database designs, database modeling.
diagram. Understand and use data manipulation language to query, update,
Students can use SQL operations to manipulate the database and and manage a database.
able to optimize query. Develop an understanding of essential DBMS concepts such as:
Students can learn how to design and create a good database using database security, integrity, concurrency.
functional dependencies and normalization. Design and build a simple database system and demonstrate
The course provides an overview of transaction management, competence with the fundamental tasks involved with modeling,
concurrency control, distributed database and Big Data. designing, and implementing a DBMS.
25 May 2022 narendrasingh@acropolis.in 19 25 May 2022 narendrasingh@acropolis.in 20

19 20

Program Education Objectives Program Outcomes (PO)


PEO1: Preparation Engineering knowledge: Apply the knowledge of mathematics, science,
engineering fundamentals, and an engineering specialization to the
Graduates will be prepared for successful technical career, higher studies, solution of complex engineering problems.
research and development and will be able to take up the challenges for
innovations, idea generation, and values. Problem analysis: Identify, formulate, review research literature, and
analyze complex engineering problems reaching substantiated
PEO2: Professionalism conclusions using first principles of mathematics, natural sciences, and
Graduates will work as an individual as well as a team on multi-disciplinary engineering sciences.
projects with effective communication skills and positive attitude. Design/development of solutions: Design solutions for complex
engineering problems and design system components or processes that
PEO3: Lifelong learning meet the specified needs with appropriate consideration for the public
Graduates will have good communication skill and social concerns to meet health and safety, and the cultural, societal, and environmental
the challenges of national and multi-national companies. considerations.
25 May 2022 narendrasingh@acropolis.in 21 25 May 2022 narendrasingh@acropolis.in 22

21 22

Program Outcomes (PO) Program Outcomes (PO)


Conduct investigations of complex problems: Use research-based Environment and sustainability: Understand the impact of the
knowledge and research methods including design of experiments, professional engineering solutions in societal and environmental
analysis and interpretation of data, and synthesis of the information to
provide valid conclusions. contexts, and demonstrate the knowledge of, and need for
sustainable development.
Modern tool usage: Create, select, and apply appropriate techniques,
resources, and modern engineering and IT tools including prediction and Ethics: Apply ethical principles and commit to professional ethics
modeling to complex engineering activities with an understanding of the and responsibilities and norms of the engineering practice.
limitations.
Individual and team-work: Function effectively as an individual, and
The engineer and society: Apply reasoning informed by the contextual
knowledge to assess societal, health, safety, legal and cultural issues and as a member or leader in diverse teams, and in multidisciplinary
the consequent responsibilities relevant to the professional engineering settings.
practice.
25 May 2022 narendrasingh@acropolis.in 23 25 May 2022 narendrasingh@acropolis.in 24

23 24

4
5/25/2022

Program Outcomes (PO) Program Specific Outcomes (PSOs) of CSE Department


Communication: Communicate effectively on complex engineering PSO1: Make use of modern languages and tools such as HTML5,
activities with the engineering community and with society at large, such CSS, MongoDB, IOS, IOT, Android, Hadoop; Work on newer
as, being able to comprehend and write effective reports and design computing paradigms such as Cloud Computing, Big Data ; Acquire
documentation, make effective presentations, and give and receive clear globally accepted certification in latest technologies such as Google
instructions. Applied CS with Android, HTML5, MongoDB, Big Data, SQL, Data
Project management and finance: Demonstrate knowledge and analytics.
understanding of the engineering and management principles and apply PSO2: Apply standard Software Engineering practices and strategies
these to one’s own work, as a member and leader in a team, to manage
projects and in multidisciplinary environments. in software project development. Learn making use of open-source
libraries in software development.
Life-long learning: Recognize the need for and have the preparation and
ability to engage in independent and life-long learning in the broadest PSO3: Emphasize on solution-oriented approach by problem
context of technological change. identification, analysis and design of computer-based system for
solving the problems of different complexities.
25 May 2022 narendrasingh@acropolis.in 25 25 May 2022 narendrasingh@acropolis.in 26

25 26

Scheme Syllabus

25 May 2022 narendrasingh@acropolis.in 27 25 May 2022 narendrasingh@acropolis.in 28

27 28

Syllabus Syllabus

25 May 2022 narendrasingh@acropolis.in 29 25 May 2022 narendrasingh@acropolis.in 30

29 30

5
5/25/2022

Reference Books Online Courses


Fundamentals of Database Systems, Ramez Elmasri,Shamkant B. Database Management Essentials, University of Colorado System by
Navathe Coursera.
Korth, Silbertz,Sudarshan, “Fundamental of Database System”, Databases: Relational Databases and SQL, Stanford University by
McGraw Hill edX.
Atul Kahate, “ Introduction to Database Management System”,
Pearson Educations
Date C J, “An Introduction To DatabaseSystem”, Pearson Educations

25 May 2022 narendrasingh@acropolis.in 31 25 May 2022 narendrasingh@acropolis.in 32

31 32

Google Classroom Planning


https://classroom.google.com/c/MzcyNjk0NDI1MTY2 NPTEL Course Enrollment
Oracle Academy Course Certificate
DBMS Projects Documentation and Implementation

25 May 2022 narendrasingh@acropolis.in 33 25 May 2022 narendrasingh@acropolis.in 34

33 34

Acknowledgement and Disclaimer


This presentation is the culmination of content extracted from a variety of sources namely
lecture notes, presentations, books and websites. In many cases, the identity of the original
contributor is not available with the author. The author wish to take this opportunity to
thank individual contributors of these extracts.
The author wishes to record that this presentation is solely used for education purpose and
copyright violation if any, is unintentional. The author is willing to remove any such extract
from the presentation with immediate effect.
The materials available at referred sites are not maintained by Acropolis Institute and we
are not responsible for the contents thereof.
All trademarks, service marks, and trade names used in this presentation are the marks of
the respective owner(s).
Narendra Pal Singh Rathore
Associate Professor, CSE
Acropolis Institute(AITR), Indore
narendrasingh@acropolis.in
25 May 2022 narendrasingh@acropolis.in 35 25 May 2022 narendrasingh@acropolis.in 36

35 36

6
5/25/2022

25 May 2022 narendrasingh@acropolis.in 37

37

7
15.Lab Manual
Acropolis Institute of Technology & Research, Indore
LAB Manual DBMS
Rational behind DBMS Lab
Database management has evolved from a specialized computer application to a central
component of a modern computing environment and as a result, knowledge about database
system has become an essential part of Information Technology. The aim of this course is to
provide an introduction to database management system, with an emphasis on foundational
concepts.
The fundamental concepts and related algorithms covered here are based on those used in
existing commercial or experimental database systems.

Objectives
At the end of the course students should
1. Have a good understanding of how DBMS architecture, particularly those concerned with
creation and maintenance of tables and database.
2. Have a good understanding of the fundamental DBMS used in computer science.
3. Be able to understand various types of queries and their execution.
4. Be able to design new database and modify existing ones for new applications and reason
about the efficiency of the result.
5. Have a fair knowledge of PL/SQL.

Software and Hardware Requirements

Software Required:
1. VB, ORACLE and/or DB2
2. VB, MSACCESS
3. VB, MS SQL SERVER 2000
4. JAVA, MYSQL
5. JAVA, ORACLE

Hardware Required:
• Processor : Pentium IV
• RAM : 4 GB
• Hard Disk : 20 GB

DBMS Lab Manual 1


Acropolis Institute of Technology & Research, Indore
DBMS Lab 1 – DDL
Objective: To implement DDL statements in SQL.
Following tables (Relations) are considered as example for the lab purpose.
• SAILORS (SID:INTEGER, SNAME:STRING, RATING:INTEGER, AGE:REAL)
• BOATS (BID:INTEGER, BNAME: STRING, COLOR: STRING)
• RESERVES (SID:INTEGER, BID:INTEGER, DAY:DATE)

Introduction about SQL


SQL (Structured Query Language) is a nonprocedural language, you specify what you want, not
how to get it. A block structured format of English key words is used in this Query language. It has
the following components.

DDL (Data Definition Language)


The SQL DDL provides command for defining relation schemas, deleting relations and modifying
relation schema.

DML (DATA Manipulation Language)


It includes commands to insert tuples into, delete tuples from and modify tuples in the database.

View definition-
The SQL DDL includes commands for defining views.
Transaction Control- SQL includes for specifying the beginning and ending of transactions.

Embedded SQL and Dynamic SQL


Embedded and Dynamic SQL define how SQL statements can be embedded with in general
purpose programming languages, such as C, C++, JAVA, COBOL, Pascal and Fortran.

Integrity
The SQL DDL includes commands for specifying integrity constraints that the data stored in the
database must specify. Updates that violate integrity constraints are allowed.

Authorization
The SQL DDL includes commands for specifying access rights to relations and views.

Data Definition Language


The SQL DDL allows specification of not only a set of relations but also information about each
relation, including-
• Schema for each relation
• The domain of values associated with each attribute.
• The integrity constraints.
• The set of indices to be maintained for each relation.
• The security and authorization information for each relation.
• The physical storage structure of each relation on disk.

DBMS Lab Manual 2


Acropolis Institute of Technology & Research, Indore
Domain types in SQL
The SQL standard supports a variety of built in domain types or data types, including-
• CHAR (SIZE):- Fixed length character data of length SIZE bytes. The maximum length is 255
bytes in Oracle 7 and 2000 bytes in Oracle 8 onwards. Default and minimum size is 1 byte.
• VARCHAR2 (SIZE):-Variable length character string having maximum length SIZE bytes. The
maximum length 2000 bytes in Oracle 7 and 4000 bytes in Oracle 8 onwards. The
minimum size is 1.
• NUMBER (L):- Numeric data with number of digits L.
• NUMBER (L, D):- Numeric data with total number of digits L and number of digits D after
decimal point.
• DATE: - Valid date range. The date ranges from Jan 1, 4712 BC to December 31, 9999 AD.
• LONG: - Character data of variable length which stores upto 2 Gigabytes of data. (A bigger
version the VARCHAR2 datatype).
• INTEGER: - Integer type of Data. It is actually a synonym for NUMBER(38)
• FLOAT: - Floating point type of Data. Very similar to NUMBER it stores zero, positive, and
negative floating-point numbers.
Along with these types of data types, Oracle supports other types of data types like
TIMESTAMP, RAW, ROWID, CLOB, NCLOB, BLOB, XMLType, etc.

DDL statement

Creating a table-
Syntax-
Create table tablename (columnname datatype(size), columnname datatype(size));
Example:
SQL> CREATE TABLE SAILORS (SID NUMBER (5), SNAME VARCHAR2 (30), RATING NUMBER
(5), AGE NUMBER (4, 2));

Adding & Deleting the Attributes and Constraints to the Table: -


To add the attribute to an existing relation we can use ALTER TABLE Command. The
following tasks you can perform through alter table command.

(i) Adding new columns:


Syntax:
ALTER TABLE tablename
ADD (newcolumnname newdatatype (size));
Example:
ALTER TABLE SAILORS ADD (SADD VARCHAR2 (50));
(ii) Modifying existing table
Syntax:
ALTER TABLE tablename
MODIFY (newcolumnname newdatatype (size));
Example:
ALTER TABLE SAILORS MODIFY (SRATING NUMBER (6) NOT NULL);

DBMS Lab Manual 3


Acropolis Institute of Technology & Research, Indore
Rename statements:
Syntax:
ALTER TABLE OLD_TABLE_NAME;
RENAME TO NEW_TABLE_NAME;
Example:
ALTER TABLE BOATS RENAME TO BOAT;

Removing/Deleting Tables-
Following command is used for removing or deleting a table.
Syntax:
DROP TABLE tablename;
Example:
SQL> DROP TABLE SAILORS;

Describe statements:
To describe the structure (column and data types) of an existing database, table, index, or
view.
Syntax:
DESC table_name;
Example:
SQL> DESC TABLE SAILORS;

Truncate statements:
To destroy the data in an existing database, table, index, or view. If a table is truncated all
records held within it are lost and cannot be recovered but the table structure is
maintained.
Syntax:
TRUNCATE TABLE table_name;
Example:
SQL> TRUNCATE TABLE SAILORS;

Data Constraints:
Besides the cell name, cell length and cell data type there are other parameters i.e. other data
constrains that can be passed to the DBA at check creation time. The constraints can either be
placed at column level or at the table level.

Column Level Constraints:


If the constraints are defined along with the column definition, it is called a column level
constraint.

Table Level Constraints:


If the data constraint attached to a specify cell in a table reference the contents of another cell in
the table then the user will have to use table level constraints.

DBMS Lab Manual 4


Acropolis Institute of Technology & Research, Indore
Null Value Concepts:-
while creating tables if a row locks a data value for particular column that value is said to be null .
Column of any data types may contain null values unless the column was defined as not null when
the table was created
Syntax:
Create table tablename (columnname data type (size) not null ……)
Example:
SQL> CREATE TABLE SAILORS (SID NUMBER (5) not null, SNAME VARCHAR2 (30), RATING
NUMBER (5), AGE NUMBER (4, 2));

NOTE
• We can also add not null constraint to existing table’s column.
Syntax:
alter table tablename modify (columnname data type (size) not null ……)
Example:
SQL> ALTER TABLE SAILORS MODIFY (SID NUMBER (5) not null);

Primary Key:
Primary key is one or more columns of a table used to uniquely identity each row in the table.
Primary key values must not be null and must be unique across the column. A multicolumn
primary key is called composite primary key.

Primary key as a column constraint


Syntax:
Create table tablename (columnname datatype (size) primary key,….)
Example:
SQL> CREATE TABLE SAILORS (SID NUMBER(5) primary key, SNAME VARCHAR2(30), RATING
NUMBER(5), AGE NUMBER(4,2));

Primary key as a table constraint


Syntax:
Create table tablename
(columnname datatype (size), columnname datatype( size)…
Primary key (columnname,columnname));
Example:
SQL> CREATE TABLE SAILORS ( SID NUMBER(5), SNAME VARCHAR2(30), RATING NUMBER(5), AGE
NUMBER(4,2), , PRIMARY KEY(SID) );

Add PRIMARY KEY to the existing table:


Syntax:
ALTER TABLE tablename ADD PRIMARY KEY (columnname);
Example:
SQL> ALTER TABLE BOAT ADD PRIMARY KEY (BID NUMBER (5));

DBMS Lab Manual 5


Acropolis Institute of Technology & Research, Indore
Default value concept:
At the line of cell creation, a default value can be assigned to it. When the user is loading a record
with values and leaves this cell empty, the DBA will automatically load this cell with the default
value specified. The data type of the default value should match the data type of the column
Syntax:
Create table tablename (columnname datatype (size) default value,….);
Example:
SQL> CREATE TABLE SAILORS (SID NUMBER(5), SNAME VARCHAR2(30), RATING NUMBER(5), AGE
NUMBER(4,2) 18 );

Foreign Key Concept:


Foreign key represents relationship between tables. A foreign key is column whose values are
derived from the primary key of the same of some other table. The existence of foreign key
implies that the table with foreign key is related to the primary key table from which the foreign
key is derived .A foreign key must have corresponding primary key value in the primary key table
to have meaning.

Foreign key as a column constraint


Syntax:
Create table table name (columnname datatype (size) references another table name);
Example:
SQL> CREATE TABLE RESERVES (SID NUMBER (5), BID NUMBER (5), DAY DATE, PRIMARY KEY (SID,
BID, DAY), FOREIGN KEY (SID) REFERENCES (SAILORS) , FOREIGN KEY (BID) REFERENCES (BOATS)
);

Foreign key as a table constraint:


Syntax:
Create table name (columnname datatype (size)….
primary key (columnname);
foreign key (columnname)references table name);
Example:
SQL> CREATE TABLE RESERVES (SID NUMBER (5), BID NUMBER (5), DAY DATE, FOREIGN KEY (SID)
REFERENCES (SAILORS));

Add FOREIGN KEY to the existing table:


Syntax:
ALTER TABLE tablename
ADD CONSTRAINT constraintname
FOREIGN KEY(columnname) REFERENCES tablename;
Example:
SQL> ALTER TABLE RESERVES ADD CONSTRAINTS F_BKEY FOREIGN KEY (BID NUMBER (5))
REFERENCES BOATS MODIFY (DAY NOT NULL);

DBMS Lab Manual 6


Acropolis Institute of Technology & Research, Indore
Check Integrity Constraints:
Use the check constraints when you need to enforce integrity rules that can be evaluated based
on a logical expression following are a few examples of appropriate check constraints.
• A check constraints name column of the client_master so that the name is entered in upper
case.
• A check constraint on the client_no column of the client _master so that no client_no value
starts with ‘c’.

Syntax:
Create table tablename
(columnname datatype (size) CONSTRAINT constraintname)
Check (expression));
Example:
SQL> CREATE TABLE SAILORS ( SID NUMBER(5), SNAME VARCHAR2(30), RATING
NUMBER(5), AGE NUMBER(4,2), , PRIMARY KEY(SID), CHECK ( RATING >=1 AND RATING
<=10) );

Dropping integrity constraints in the ALTER TABLE command:


You can drop integrity constraint if the rule that if enforces is no longer true or if the constraint is
no longer needed. Drop the constraint using the ALTER TABLE command with the DROP clause.
The following examples illustrate the dropping of integrity constraints.

DROP the PRIMARY KEY


Syntax:
ALTER TABLE tablename
DROP PRIMARY KEY
Example:
ALTER TABLE SAILOR DROP PRIMARY KEY;

DROP FOREIGN KEY


Syntax:
ALTER TABLE tablename
DROP CONSTRAINT constraintname;
Example:
ALTER TABLE RESERVES DROP CONSTRAINT F_BKEY;

DBMS Lab Manual 7


Acropolis Institute of Technology & Research, Indore
ASSIGNMENT NO.1
Q1. Create the following tables:

i) Client_master (CM)
Columnname Datatype Size Attributes
cno varchar2 6 Primary key / first letter must start
with ’c’
Name varchar2 20
address1 varchar2 30
address2 varchar2 30
City varchar2 15
State varchar2 15
Pincode Number 6
bal_due Number 10,2

ii) Product_master (PM)


Columnname Datatype Size Attributes
pno varchar2 6 Primary key / first letter must start
with ’p’
Description varchar2 15 Not NULL
Profit_percent Number 4,2 Not NULL
Unit_measure varchar2 10 Not NULL
Qty_on_hand Number 8 Not NULL
Reoder_lvl Number 8 Not NULL
Sell_price Number 8,2 Not NULL, Cannot be 0
Cost_price Number 8,2 Not NULL, Cannot be 0

iii) Salesman_master (SM)


Columnname Datatype Size Attributes
Sno varchar2 6
S_name varchar2 20 Not null
Address1 varchar2 30 Not null
Address2 varchar2 30
City varchar2 20
Pincode Number 8
State varchar2 20
Sal_amt Number 8,2 Not null, cannot be 0
Tgt_to_get Number 6,2 Not null, cannot be 0
Ytd_sales Number 6,2 Not null
Remarks Varchar2 60

DBMS Lab Manual 8


Acropolis Institute of Technology & Research, Indore
iv) Sales_order (SO)
Columnname Datatype Size Attributes
sono varchar2 6 Primary key / first letter must be ‘o’
Cno Varchar2 6 Foreign key reference clien_no of
client_master table
S_order_date Date Not Null
Dely_add Varchar2 25
Sno Varchar2 6 Foreign key references salesman_no
of salesman_master table
Dely_type Char 1 Delivery: part(p)/full(f)
Billed_yn Char 1
Dely_date Date Cannot be lessthan s_order_date
Order_status Varchar2 10 Values (‘in process’;’fulfilled’;back
order’;’canceled’)

v) Sales_order_details (SOD)
Discription: used to store client’s orders with details of each product ordered.
Columnname Datatype Size Attributes
Sono Varchar2 6 Foreign key references
s_order_no of sales_order table.
Pno Varchar2 6 Foreign key references
product_no of product_master table.
Qty_order Number 8
Qty_disp Number 8
Product_rate Number 10,2

Exercise on altering the table structure.


a. Add a column called_tel of datatype Number and size=10 to the client_master table.
b. Change the size of sell_prize column in product_master to 10, 2.

Exercise on deleting the table structure along with the data.


a. Destroy the table client_master along with its data.

Exercise on renaming the table.


a. Change the name of salesman_master to sman_mast.

Exercise on adding & removing of constraints on existing table.


a. In the salesman_master table make salesman_no. as primary key and its first letter should
be started with’s’.
b. Add a constraint names as chk_cons to the table client_master that will check that the
name should not be null.
c. Drop the foreign key product_no. from sales_order_details.

DBMS Lab Manual 9


Acropolis Institute of Technology & Research, Indore

DBMS Lab 2 – DML and Data Retrieval


Objective: - To Manipulate the Operations on the table.

DML (Data Manipulation Language)


Data manipulation is
• The retrieval of information stored in the database.
• The insertion of new information into the database.
• The deletion of information from the database.
• The modification of information stored by the appropriate data model.

There are basically two types.


(i) Procedural DML: - require a user to specify what data are needed and how to get
those data.
(ii) Non Procedural DML: require a user to specify what data are needed without
specifying how to get those data.
1) Insertion of data into tables-
Syntax-
INSERT INTO tablename
[(columnname, columnname, ………)]
Values (expression, expression);
Example:
SQL> INSERT INTO SAILORS (SNAME, SID, AGE, RATING) VALUES (‘Rajesh’, 1, 30, 10);

By using this method we can add records or data to Sailors, Boats as well as Reserves
Table.

2) Retrieving of data from the tables-


Syntax-
SELECT * FROM tablename;
Example:
SQL> SELECT * FROM SAILORS;

3) The retrieving of specific columns from a table-


Syntax-
SELECT columnname, columnname, ….
FROM tablename;
Example:
SQL> SELECT SNMAE, AGE FROM SAILORS;

4) Creating a table from a table-


Syntax-
CREATE TABLE TABLENAME [(columnname, columnname, ………)]
AS SELECT columnname, columnname....... FROM tablename;

DBMS Lab Manual 10


Acropolis Institute of Technology & Research, Indore
Example:
SQL> CREATE TABLE RESERVE (SID NUMBER(5),BID NUMBER(5)) AS SELECT SID FROM
SAILOR;

5) Selecting a data set from table data using where clause-


Syntax-
SELECT columnname, columnname FROM tablename
WHERE searchcondition;
Example: Display names & ages of all sailors whose Rating >7.
SQL> SELECT SNMAE, AGE FROM SAILORS WHERE (RATING>4);

6) Inserting data into a table from another table:


Syntax-
INSERT INTO tablename
SELECT columnname, columnname, …….
FROM tablename;
Example:
SQL> INSERT INTO RESERVE (SELECT SID FROM SAILOR);

7) Insertion of selected data into a table from another table:


Syntax-
INSERT INTO tablename
SELECT columnname, columnname........ FROM tablename
WHERE columnname= expression;
Example:
SQL> INSERT INTO RESERVE (SELECT SID FROM SAILOR WHERE (SNAME=’Rajesh’));

8) Updating the content of a table:


In creation situation we may wish to change a value in table without changing all values in
the tuple . For this purpose the update statement can be used.
Syntax-
Update table name
Set columnname = expression, columnname =expression……
Where columnname = expression;
Example:
SQL> UPDATE SAILORS SET RATING = RATING + 1;

9) Deletion Operation:-
A delete query is expressed in much the same way as Query. We can delete whole tuple
(rows) we can delete values on only particulars attributes.
Deletion of all rows
Syntax:
Delete from tablename:
Example:
SQL> DELETE FROM SAILORS;

DBMS Lab Manual 11


Acropolis Institute of Technology & Research, Indore
10) Deletion of specified number of rows
Syntax:
Delete from table name
Where search condition;
Example:
SQL> DELETE FROM SAILORS WHERE SNAME = ‘Rajesh’;

DBMS Lab Manual 12


Acropolis Institute of Technology & Research, Indore
ASSIGNMENT NO. 2
Q1- Insert the following data into their respective tables:
i) client_master(CM)
Cno Name city Pincode state bal.due
C00001 Ivan Bayross Mumbai 400054 Maharashtra 15000
C00002 Mamta Madras 780001 Tamilnadu 0
Mazumdar
C00003 Chhaya Bankar Mumbai 400057 Maharashtra 5000
C00004 Ashwini Joshi Banglore 560001 Karnataka 0
C00005 Hansel Colaco Mumbai 400060 Maharashtra 2000
C00006 Deepak Sharma Mangalore 560050 Karnataka 0

ii) product_master(PM)
PNo Description Profit% Unit Qty Reorder Sell price Cost
Percent measured on hand price
P00001 T-Shirts 5 piece 200 50 350 250
P0345 Shirts 6 piece 150 50 500 350
P06734 Cotton Jeans 5 piece 100 20 600 450
P07865 Jeans 5 piece 100 20 750 500
P07868 Trousers 2 piece 150 50 850 550
P07885 Pull Overs 2.5 piece 80 30 700 450
P07965 Denim Shirts 4 piece 100 40 350 250
P07975 Lycra Tops 5 piece 70 30 300 175
P08865 Skirts 5 piece 75 30 450 300

iii) salesman_master (SM)


Sno S_name Addr Address City Pin State Salam Tgt_ Ytd Rem
ess1 1 code t to_get Sales
S00001 Aman A/14 worli Mumbai 400002 Mah 3000 100 50 Good
S00002 Omkar 65 Nariman Mumbai 400001 Mah 3000 200 100 Good
S00003 Raj P-7 Bandra Mumbai 400032 Mah 3000 200 100 Good
S00004 Ashish A/5 Juhu Mumbai 400044 Mah 3500 200 150 Good

On the basis of client_master & product_master tables answer the following Questionnaires:
a. Find out the names of all the clients.
b. Retrieve the entire contents of client_master table.
c. Retrieve the list of names, city and state of all the clients.
d. List the various products available from the product_master table.
e. List all the clients who are located in Mumbai.
f. List the names of salesmen who have a salary equal to Rs. 3000

DBMS Lab Manual 13


Acropolis Institute of Technology & Research, Indore
Exercise on updating records in a table.
a. Change the city of client no. ‘C00005’ to ‘Banglore’.
b. Change the bal_due of client no. ‘C00001’ to Rs. 1000.
c. Change the cost price of Trousers to Rs. 950.00.
d. Change the city of salesmen to ‘Pune’.

iv) sales_order table (SO):


Sono Cno S_orderdate Sno Dely Bill Y/N Delay date Orderstatus
type
O19001 C00001 12-June-04 S00001 F N 20-July-02 In Process
O19002 C00002 25-June-04 S00002 P N 27-June-02 Cancelled
O46865 C00003 18-Feb-04 S00003 F Y 20-Feb-02 Fulfilled
O19003 C00001 03-Apr-04 S00001 F Y 07-Apr-02 Fulfilled
O46866 C00004 20-May-04 S00002 P N 22-May-02 Cancelled
O19008 C00005 24-May-04 S00004 F N 26-July-02 In Process

v) sales_order_details table (SOD):


Sono Pno Qty ordered Qty disp Product_rate
O19001 P00001 4 4 525
O19001 P07965 2 1 8400
O19001 P07885 2 1 5250
O19002 P00001 10 0 525
O46865 P07868 3 3 3150
O46865 P07885 3 1 5250
O46865 P00001 10 10 525
O46865 P0345 4 4 1050
O19003 P03453 2 2 1050
O19003 P06734 1 1 12000
O46866 P07965 1 0 8400
O46866 P07975 1 0 1050
O19008 P00001 10 5 525
O19008 P07975 5 3 1050

Exercise on deleting records in a table


a. Delete all salesmen from the salesman_master whose salaries are =3500.
b. Delete all products from product_master where qty_on_hand =100.
c. Delete from client_master where the column state holds the value ‘Tamilnadu’.

DBMS Lab Manual 14


Acropolis Institute of Technology & Research, Indore

DBMS Lab 3 – Advance Data Retrieval


Logical Operators:
The logical operators that can be used in SQL sentenced are

AND: -
Returns TRUE if both component conditions are TRUE. Returns FALSE if either is FALSE;
otherwise returns UNKNOWN.
Syntax:
Select columnname from tablename where(Condition 1 AND Condition 2);
Example: -
Find the names of sailor's that have reserved both a red and a green boat.
SQL> SELECT S.SNAME FROM SAILORS S, RESERVES R1, BOATS B1, RESERVES R2, BOATS B2
WHERE S.SID = R1.SID AND R1.BID = B1.BID AND S.SID = R2.SID AND R2.BID = B2.BID AND=
B1.COLOR='RED' AND B2.COLOR = 'GREEN';

OR: -
Returns TRUE if either component condition is TRUE. Returns FALSE if both are FALSE.
Otherwise, returns UNKNOWN.
Syntax:
Select columnname from tablename where(Condition 1 AND Condition 2);
Example: - Find the names of sailors who have reserved a red or a green boat.
SQL> SELECT S.SNAME FROM SAILORS S, RESERVES R, BOATS B WHERE S.SID = R.SID AND
R.BID = B.BID AND (B.COLOR = 'RED' OR B.COLOR = 'GREEN');

NOT: -
Returns TRUE if the following condition is FALSE. Returns FALSE if it is TRUE. If it is
UNKNOWN, it remains UNKNOWN.
Syntax:
Select columnname from tablename where NOT(Condition );
Example: -
Ex: - Find the SIDs of all sailor's who have reserved red boats but not green boats.
SQL> SELECT S.SID FROM SAILORS S, RESERVES R, BOATS B WHERE S.SID = R.SID AND R.BID
= B.BID AND B.COLOR = 'RED' NOT (SELECT S2.SID FROM SAILORS S2, RESERVES R2, BOATS
B2 WHERE S2.SID = R2.SID AND R2.BID = B2.BID AND B2.COLOR = 'GREEN’);

DISTINCT Keyword: -
The DISTINCT keyword eliminates the duplicate tuples from the result records set.
Syntax-
SELECT DISTINCT columnname, columnname
FROM tablename;
Example: - Find the Names and Ages of all sailors.
DBMS Lab Manual 15
Acropolis Institute of Technology & Research, Indore
SQL> SELECT DISTINCT S.SNAME, S.AGE FROM SAILORS S;
The answer is a set of rows, each of which is a pair (sname, age). If two or more sailors have the
same name and age, the answer still contains just one pair with that name and age.

AGGREGATE Functions: -
Functions are used to manipulate data items and return result. Function follow the format of
function _name (argument1, argument2 ..) .An arrangement is user defined variable or constant.
The structure of function is such that it accepts zero or more arguments.
In addition to simply retrieving data, we often want to perform some computation or
summarization. We now consider a powerful class of constructs for computing aggregate values
such as MIN and SUM. These features represent a significant extension of relational algebra. SQL
supports five aggregate operations, which can be applied on any column, say A, of a relation:

COUNT: -
The number of values in the A column.
Syntax:
Count ([distinct/all) A]
Or
COUNT (DISTINCT A): The number of unique values in the A column.
Count (*) Returns the no rows in the table, including duplicates and those
with nulls.
Example: -
1) To count number SIDs of sailors in Sailors table
SQL> SELECT COUNT (SID) FROM SAILORS;
2) To count numbers of boats booked in Reserves table.
SQL> SELECT COUNT (DISTINCT BID) FROM RESERVES;
3) To count number of Boats in Boats table.
SQL> SELECT COUNT (*) FROM BOATS;

SUM:-
Syntax
SUM (A):- The sum of all values in the A column.
Or
SUM (DISTINCT A): The sum of all unique values in the A column.
Example: -
1) To find sum of rating from Sailors
SQL> SELECT SUM (RATING) FROM SAILORS;
2) To find sum of distinct age of Sailors (Duplicate ages are eliminated).
SQL> SELECT SUM (DISTINCT AGE) FROM SAILORS;

AVG
Syntax
AVG (A):- The average of all values in the A column.
Or
AVG (DISTINCT A): The average of all unique values in the A column.
DBMS Lab Manual 16
Acropolis Institute of Technology & Research, Indore
Example: -
1) To display average age of Sailors.
SQL> SELECT AVG (AGE) FROM SAILORS;
2) To find average of distinct age of Sailors (Duplicate ages are eliminated).
SQL> SELECT AVG (DISTINCT AGE) FROM SAILORS;

MAX
Syntax
M A X (A ) : - The maximum value in the A column.
Example: -
1) To find age of Oldest Sailor.
SQL> SELECT MAX (AGE) FROM SAILORS;

MIN:-
Syntax
MIN (A):- The minimum value in the A column.
Example: -
1) To find age of Youngest Sailor.
SQL> SELECT MIN (AGE) FROM SAILORS;

Range Searching:
Between operations is used for range searching.
Syntax:
Select columnname from tablename where (search condition) BETWEEN (Value 1 AND Value 2);
Example: -Find the Sailor’s with the rating between 1 to 5
SQL> SELECT S.SID FROM SAILORS S WHERE S.RATING BETWEEN (1 AND 5);

Pattern Searching:
The most commonly used operation on string is pattern matching using the operation ‘like’ we
describe patterns by using two special characters.
• Percent (%); the % character matches any substring we consider the following examples.
• ‘Perry %’ matches any string beginning with Perry.
• ‘% idge % matches any string containing’ idge as substring.
• ‘ - - - ‘ matches any string exactly three characters.
• ‘ - - - % matches any string of at least of three characters.
Syntax:
Select columnname from tablename where (search condition) like %an%.
Select columnname from tablename where (search condition) like %-----.
Select columnname from tablename where (search condition) like %.
Example: -
1. Select the name of the Sailor’s whose name contain ‘an’ as substring.
SQL> SELECT S.SNAME FROM SAILORS S WHERE S.SNAME LIKE ‘%an%’.
2. Select the name of the Sailor’s whose name starts with ‘Ra’.
SQL> SELECT S.SNAME FROM SAILORS S WHERE S.SNAME LIKE ‘Ra%’.

DBMS Lab Manual 17


Acropolis Institute of Technology & Research, Indore
3. Select the name of the Sailor’s whose name ends with ‘am’.
SQL> SELECT S.SNAME FROM SAILORS S WHERE S.SNAME LIKE ‘%am’.
4. Select the name of the Sailor’s whose name is of exactly 5 characters.
SQL> SELECT S.SNAME FROM SAILORS S WHERE S.SNAME LIKE’ ---- ’.

DBMS Lab Manual 18


Acropolis Institute of Technology & Research, Indore
ASSIGNMENT NO.3
Answer the following Queries:
Using the tables created previously generate the SQL statements for the operations mentioned
below. The tables in use are as follows:
a. Client_master
b. Product_master
c. Salesman_master
d. Sales_order
e. Sales_order_details

Perform the following computation on table data.


a. List the names of all clients having ‘a’ as second letter in their names.
b. List the clients who stay in the city whose first letter is ‘M’.
c. List all clients who stay in ‘Bangalore’ or ‘Mangalore’.
d. List all clients whose bal_due is greater than value 10000.
e. List all information from sales_order for orders placed in the month of June.
f. List the order information for the client no. ‘C00001’ and ‘C00002’.
g. List products whose selling price is greater than 500 and less than or equal to 750.
h. List products whose selling price is more than 500. Calculate a new selling price as, original
selling price *.15. Rename the new column in the output of the above query as new_price.
i. List the names, city and state of clients who are NOT in the state of ‘Maharashtra’.
j. Count the total no. of orders.
k. Calculate the average price of all products.
l. Determine the maximum and minimum product prices. Rename the output as max_price
and min_price respectively.
m. Count the number of products having price less than or equal to 500.
n. List all the products whose qnty_on_hand is less than reorder_lvl.

DBMS Lab Manual 19


Acropolis Institute of Technology & Research, Indore
Queries using In-built Functions
Conversion Functions :-
These functions are used to convert the value from one type to another type.

to_char, to_number and to_date.

TO_CHAR (N [,FMT]) :- Converts ‘N’ of numeric data type to Varchar2 datatype using optional
number format FMT.

Ex 1) Convert 12345 to string.

SQL> SELECT TO_CHAR(12345) FROM DUAL;

Ex 2)Display system date after converting to varchar2 data type.

SQL> SELECT TO_CHAR(SYSDATE) FROM DUAL;

Ex 3)Display system date in ‘Mon-DD-YYYY’ format after converting to varchar2 data type. SQL>
SELECT TO_CHAR(SYSDATE, ‘Mon-DD-YYYY’) FROM DUAL;

TO_NUMBER(CHAR) :- This conversion function is used to convert string to number data type.

Ex :- Convert string ‘123.45’ to number data type.

SQL> SELECT TO_NUMBER(‘123.45’) FROM DUAL;

TO_DATE :- Converts character data type data to date type data.

Ex:- Display ’09-02-20 10’ converted to DDD-MM-YY format using to_char & to_date functions.
SQL> SELECT TO_CHAR(TO_DATE(’09-02-20 10’, ‘DD-MM-YYYY’),(‘DDD-MM-YY’) FROM DUAL;

Formats we can use for Date :- Following formats can be used with any function related to dates.

• Y : Last digit in the year.


• YY : Last two digits in the year.
• YYYY : Year in four digits.
• YEAR : Year in characters.
• MM : Month in digits.
• MONTH :Month in characters.
• MON : Month in formatted with three characters.
• D : Day of Week.
• DD : Day of the Month.

DBMS Lab Manual 20


Acropolis Institute of Technology & Research, Indore
• DDD : Day of the Year.
• DAY : Day name.
• HH or HH12 or HH24 : Hours in 12 Hrs or 24 Hrs format.
• MI : Minutes.
• SS : Seconds.

String Functions:
Concatenation, lpad, rpad, ltrim, rtrim, lower, upper, initcap, length, substr and instr.

Concatenation :- Concatenates two stings from a given list. CANCAT (CHAR1, CHAR2)

EX 1) Concate the string ‘Rajesh’ with ‘Raghu’

SQL> SELECT CONCAT (‘Rajesh’, ‘Raghu’) FROM DUAL;

EX 2) Concat bid & bname of Boats & display along with color.

SQL> SELECT CONCAT(BID, BNAME), COLOR FROM BOATS;

LPAD (CHAR1, N, CHAR2) :- Returns CHAR1 left padded to length ‘N’ with sequence of
characters in CHAR2. The default value of CHAR2 is a single blank space. Ex 1) Lpad the string
‘Rajesh’ to length 30 with the set of characters in string ‘-*-’ SQL> SELECT LPAD(‘Rajesh’, 30, ‘-*-’)
FROM DUAL;

2) Lpad the string bname to length 20 with ‘-*’ set of characters and string color by ‘/’.

RPAD (CHAR1, N, CHAR2) :- Returns CHAR1 right padded to length ‘N’ with sequence of
characters in CHAR2. The default value of CHAR2 is a single blank space.

Ex 1) Rpad the string ‘Rajesh’ to length 30 with the set of characters in string ‘*#’ SQL> SELECT
RPAD(‘Rajesh’, 30, ‘*#’) FROM DUAL;

2) Rpad the string sname to length 20 with ‘-*’ set of characters and remaining attributes in
normal way.

LTRIM (CHAR, SET) :- Returns characters from the left of CHAR by deleting all leftmost
characters that appear in set.

Ex:- Display all sailors information by removing characters of sname if starts with ‘R’. SQL> SELECT
SID, LTRIM(SNAME,’R’) FROM SAILORS;

RTRIM (CHAR, SET) :- Returns characters from the right of CHAR by deleting all rightmost
characters that appear in set.

DBMS Lab Manual 21


Acropolis Institute of Technology & Research, Indore
Ex:- Display all sailors information by removing characters of sname if ends with ‘i’. SQL> SELECT
SID, RTRIM(SNAME,’i’) FROM SAILORS;

LOWER(CHAR) :- Converts all characters to lowercase characters in a sting CHAR. Ex:- Display all
Boats information by showing their names in lower case.

SQL> SELECT BID, LOWER(BNAME), COLOR FROM BOATS;

UPPER(CHAR) :- Converts all characters to uppercase characters in a sting CHAR. Ex:- Display all
Sailors information by showing their names in Upper case.

SQL> SELECT SID, UPPER(SNAME), AGE, RATING FROM SAILORS;

INITCAP(CHAR) :- Converts first character of each word in a sting CHAR to uppercase. Ex:-1)
Display all Sailors information by showing their names in Capitalizing first char. SQL> SELECT SID,
INITCAP(SNAME), AGE, RATING FROM SAILORS;

2) Capatilize first letter of each word in ‘rajesh raghu’

SQL> SELECT INITCAP(‘rajesh raghu’) FROM DUAL;

LENGTH (CHAR) :- Returns the length of the string CHAR i.e. number of characters present in
the given string.

Ex: -1) Find the number of characters in the string ‘Information Technology’

SQL> SELECT LENGTH (‘Information Technology’) FROM DUAL;

2) Display length of string SID, SNAME from Sailors along with their values.

SQL> SELECT SID, LENGTH(SID), SNAME, LENGTH(SNAME) FROM SAILORS;

SUBSTR(CHAR, M, N) :- It returns substring from CHAR string starting with index M & gives N
characters.

Ex : Display boats information by starting their names with 3rd character & show only 4
characters.

SQL> SELECT BID, SUBSTR(BNAME, 3, 4), COLOR FROM BOATS;

INSTR(CHAR1, CHAR2, M, N) :- It searches CHAR1 beginning with Mth character for Nth
occurrence of CHAR2 and returns the position after character in CHAR 1. If N is negative value,
then it searches backwards from the end of CHAR1.

The default value of M & N is 1.

DBMS Lab Manual 22


Acropolis Institute of Technology & Research, Indore
Ex : Display the index of string ‘ab’ after 2nd character & 3rd occurrence in the given string
‘abcdabcdababab’.

SQL> SELECT INSTR (‘abcdabcdababab’,’ab’, 2, 3) FROM DUAL;

TRANSLATE(CHAR, FROM, TO) :- It returns characters with all occurrences of each character
in FROM replaced by its corresponding character in TO.

Ex :1) Replace ‘a’ with ‘d’ in the given string ‘abcdabcdababab’.

SQL> SELECT TRANSLATE (‘abcdabcdababab’, ’a’, ’b’) FROM DUAL;

2) Display Sailors information by replacing ‘a’ with ‘i’ from SNAME, if any.

SQL> SELECT SID, TRANSLATE(SNAME,’a’,’i’ ) FROM SAILORS;

REPLACE(CHAR, S, R) :- It returns characters with every occurrences of S replaced with R. If R is


not given or NULL, all occurrences of S are removed or deleted.

Ex :1) Display BNAME by replacing ‘da’ with ‘ma’.

SQL> SELECT REPLACE (BNAME, ‘da’, ‘ma’) FROM BOATS;

Date Functions :
Sysdate, next_day, add_months, last_day, months_between, least, greatest, trunc, round,
to_char, to_date.

SYSDATE :- Displays the system date for a system.

SQL> SELECT SYSDATE FROM DUAL;

SQL> SELECT TO_CHAR (SYSDATE, 'DD-MON-YYYY HH:MI:SS') FROM dual;

NEXT_DAY (D, DAY) :- Displays next date on DAY after date D. Ex: Display date on Thu after
20th Feb, 2010. SQL> SELECT NEXT_DAY (’20-FEB-2010’, ‘THU’) FROM DUAL;

ADD_MONTHS (D, N) :- Returns a date after adding a specified day D with specified number of
months N. Display SID, Day of Reservation by adding 20 months to given day.

SQL> SELECT SID, DAY, ADD_MONTHS (DAY, 20) FROM RESERVES;

LAST_DAY(D) :- Returns the date corresponding to last day of the month. Ex: Display Sname,
Day of Reservation and date corresponding to last date of the month. SQL> SELECT S.SNAME,
DAY, LAST_DAY (DAY) FROM SAILORS S, RESERVES R WHERE S.SID = R.SID;

DBMS Lab Manual 23


Acropolis Institute of Technology & Research, Indore
MONTHS_BETWEEN (D1, D2) :- Returns number of months between given two dates D1 & D2.

Ex: Display SID, Day of Reservation and months between System Date & day of reservation. SQL>
SELECT SID, DAY, MONTHS_BETWEEN (SYSDATE, DAY) FROM RESERVES;

DBMS Lab Manual 24


Acropolis Institute of Technology & Research, Indore
DBMS Lab 4 – Sub, Correlated, Nested and Set Queries
SubQueries: -
A subQuery is a form of an SQL statement that appears inside another SQL statement. It also
termed as nested Query. The statement containing a subQuery called a parent statement. The
rows returned by the subQuery are used by the following statement.
It can be used by the following commands:
1. To insert records in the target table.
2. To create tables and insert records in this table.
3. To update records in the target table.
4. To create view.
5. To provide values for the condition in the WHERE, HAVING IN, SELECT, UPDATE, and
DELETE statements.
Example:-
Creating clientmaster table from oldclient_master, table
SQL> Create table client_master AS SELECT * FROM oldclient_master;

CORRRELATED SUBQUERY
A subquery which executes once for each and every row of main query is called correlated
subquery.
It is mainly used for row by row process
The main difference between Correlated subquery and subquery is that in Subquery(child
Query), Main Query is executed first.

Set Operators: UNION, INTERSECT, EXCEPT (MINUS):-


SQL provides three set-manipulation constructs that extend the basic query form. Since the
answer to a query is a multi set of rows, it is natural to consider the use of operations such as
union, intersection, and difference. SQL supports these operations under the names UNION,
INTERSECT and MINUS.
Note that UNION, INTERSECT, and MINUS can be used on any two tables that are union-
compatible, that is, have the same number of columns and the columns, taken in order, have the
same types.

UNION: -
The user can put together multiple Queries and combine their output using the union clause. The
union clause merges the output of two or more Queries into a single set of rows and column. The
final output of union clause will be
Output: = Records only in Query one + records only in Query two + A single set of records with is
common in the both Queries.
Syntax:
SELECT columnname, columname FROM tablename 1
DBMS Lab Manual 25
Acropolis Institute of Technology & Research, Indore
UNION
SELECT columnname, columnname From tablename2;
Example:
1) Find the names of sailors who have reserved a red or a green boat.
SQL> SELECT S.SNAME FROM SAILORS S, RESERVES R, BOATS B WHERE S.SID = R.SID AND
R.BID = B.BID AND B.COLOR = 'RED' UNION SELECT S2.SNAME FROM SAILORS S2, BOATS
B2, RESERVES R2 WHERE S2.SID = R2.SID AND R2.BID = B2.BID AND B2.COLOR = 'GREEN';

INTERSECT: -
The use can put together multiple Queries and their output using the interest clause. The final
output of the interest clause will be:
Output =A single set of records which are common in both Queries
Syntax:
SELECT columnname, columnname FROM tablename 1
INTERSECT
SELECT columnname, columnname FROM tablename 2;
Example:
1) Find the names of sailor's that have reserved both a red and a green boat.
SQL> SELECT S.SNAME FROM SAILORS S, RESERVES R, BOATS B WHERE S.SID = R.SID AND
R.BID = B.BID AND B.COLOR = ‘RED’ INTERSECT SELECT S2.SNAME FROM SAILORS S2,
BOATS B2, RESERVES R2 WHERE S2.SID = R2.SID AND R2.BID = B2.BID AND B2.COLOR =
'GREEN';

EXCEPT (MINUS):-
The user can put together multiple Queries and combine their output = records only in Query one
Syntax:
SELECT columnname, columnname FROM tablename ;
MINUS
SELECT columnname, columnname FROM tablename ;
Example: -

1) Find the SIDs of all sailors’s who have reserved red boats but not green boats.
SQL> SELECT S.SID FROM SAILORS S, RESERVES R, BOATS B WHERE S.SID = R.SID AND R.BID
= B.BID AND B.COLOR = 'RED' MINUS SELECT S2.SID FROM SAILORS S2, RESERVES R2,
BOATS B2 WHERE S2.SID = R2.SID AND R2.BID = B2.BID AND B2.COLOR = 'GREEN’;
Same query can be written as follows. Since the Reserves relation contains SID
information, there is no need to look at the Sailors relation, and we can use the following
simpler query
SQL> SELECT R.SID FROM BOATS B, RESERVES R WHERE R.BID = B.BID AND B.COLOR =
'RED' MINUS SELECT R2.SID FROM BOATS B2, RESERVES R2 WHERE R2.BID = B2.BID AND
B2.COLOR = ‘GREEN’;

DBMS Lab Manual 26


Acropolis Institute of Technology & Research, Indore
NESTED QUERIES: -
For retrieving data from the tables we have seen the simple & basic queries. These queries
extract the data from one or more tables. Here we are going to see some complex & powerful
queries that enables us to retrieve the data in desired manner. One of the most powerful features
of SQL is nested queries. A nested query is a query that has another query embedded within it;
the embedded query is called a subquery.

IN Operator: -
The IN operator allows us to test whether a value is in a given set of elements; an SQL query is
used to generate the set to be tested.
Syntax:
Select columnname from tablename where columnname IN (Search condition);
Example: -
Find the names of sailors who have reserved boat 103.
SQL> SELECT S.SNAME FROM SAILORS S WHERE S.SID IN (SELECT R.SID FROM RESERVES R WHERE
R.BID = 103);

NOT IN Operator: -
The NOT IN is used in an opposite manner to IN.
Syntax:
Select columnname from table name where columnname NOT IN (Search condition);
Example:-
Find the names of sailors who have not reserved boat 103.
SQL> SELECT S.SNAME FROM SAILORS S WHERE S.SID NOT IN (SELECT R.SID FROM RESERVES R
WHERE R.BID = 103);

EXISTS Operator: -
This is a Correlated Nested Queries operator. The EXISTS operator is another set comparison
operator, such as IN. It allows us to test whether a set is nonempty, an implicit comparison with
the empty set.
Syntax:
Select columnname from tablename where EXISTS (Search condition);
Example: - Find the names of sailors who have reserved boat number 103.
SQL> SELECT S.SNAME FROM SAILORS S WHERE EXISTS (SELECT * FROM RESERVES R WHERE
R.BID = 103 AND R.SID = S.SID);

NOT EXISTS Operator: -


The NOT EXISTS is used in a opposite manner to EXISTS.
Syntax:
Select columnname from table name where NOT EXISTS (Search condition);
Example:- Find the names of sailors who have not reserved boat number 103.
SQL> SELECT S.SNAME FROM SAILORS S WHERE NOT EXISTS (SELECT * FROM RESERVES R WHERE
R.BID = 103 AND R.SID = S.SID);

DBMS Lab Manual 27


Acropolis Institute of Technology & Research, Indore
Set-Comparison Operators:-
We have already seen the set-comparison operators EXISTS, IN along with their negated versions.
SQL also supports op ANY and op ALL, where op is one of the arithmetic comparison operators {<,
<=, =, <>, >=, >}. Following are the example which illustrates the use of these Set-Comparison
Operators.

Op ANY Operator :-
It is a comparison operator. It is used to compare a value with any of element in a given set.
Syntax:
Select columnname from tablename where (condition1) ANY (condition 2);
Example: - Find sailors whose rating is better than some sailor called Rajesh.
SQL> SELECT S.SID FROM SAILORS S WHERE S.RATING > ANY (SELECT S2.RATING FROM SAILORS
S2 WHERE S2.SNAME = ' RAJESH ‘);
Note that IN and NOT IN are equivalent to = ANY and <> ALL, respectively.

Op ALL Operator :-
It is a comparison operator. It is used to compare a value with all the elements in a given set.
Syntax:
Select columnname from tablename where (condition1) ALL (condition 2);
Example: - Find the sailor's with the highest rating using ALL.
SQL> SELECT S.SID FROM SAILORS S WHERE S.RATING >= ALL (SELECT S2.RATING FROM SAILORS
S2)

Grouping Data from Tables:


There are circumstances where we would like to apply the aggregate function not only to a single
set of tuples, but also to a group of sets of tuples, we specify this wish in SQL using the group by
clause. The attribute or attributes given in the group by clause are used to form group. Tuples
with the same value on all attributes in the group by clause are placed in one group.
Syntax:
SELECT columnname, columnname FROM tablename
GROUP BY columnname;
Example: -
1) Find the age of the youngest sailor for each rating level.
SQL> SELECT S.RATING, MIN (S.AGE) FROM SAILORS S GROUP BY S.RATING;
At times it is useful to state a condition that applies to groups rather than to tuples. For example
we might be interested in only those branches where the average account balance is more than
1200. This condition does not apply to a single tuple; rather it applies to each group constructed
by the GROUP BY clause. To express such Questioner, we use the having clause of SQL. SQL
applies predicates in the having may be used.

Syntax:
SELECT columnname, columnname FROM tablename
GROUP BY columnname;
HAVING searchcondition;

DBMS Lab Manual 28


Acropolis Institute of Technology & Research, Indore
Example: -
1) Find the age of youngest sailor with age >= 18 for each rating with at least 2 such sailors.
SQL> SELECT S.RATING, MIN (S.AGE) AS MINAGE FROM SAILORS S WHERE S.AGE >= 18
GROUP BY S.RATING HAVING COUNT (*) > 1;

ORDER BY Clause: -
The ORDER BY keyword is used to sort the result-set by a specified column. The ORDER BY keyword
sorts the records in ascending order by default (we can even use ASC keyword). If we want to sort
the records in a descending order, we can use the DESC keyword.
Syntax:
SELECT columnname, columnname FROM tablename
ORDER BY columnnames [ASC|DESC];
Example:-
1) Display all the sailors according to their ages.
SQL> SELECT * FROM SAILORS ORDER BY AGE;
2) Display all the sailors according to their ratings (topper first).
SQL> SELECT * FROM SAILORS ORDER BY RATING DESC;
3) Displays all the sailors according to rating, if rating is same then sort according to
age.
SQL> SELECT * FROM SAILORS ORDER BY RATING, AGE;

DBMS Lab Manual 29


Acropolis Institute of Technology & Research, Indore
ASSIGNMENT NO.4
Exercise on sub-queries.

a. Find the product_no and description of non- moving products i.e. products not being sold.
b. Find the customer name, address1, address2, city and pincode for the client who has
placed order no “019001”.
c. Find the client names that have placed order before the month of May’02.
d. List if the product ‘Lycra Top’ has been ordered by any client and print the client_no.,
name to whom it was sold.
e. List the names of clients who have placed orders worth Rs. 10000 or more.

Exercise on Having and Group By Clauses:

a. Print the description and total quantity sold for each product.
b. Find the value of each product sold.
c. Calculate the average quantity sold for each client that has a maximum order value of
15000.00.
d. Find out the total of all the billed orders for the month of June.

DBMS Lab Manual 30


Acropolis Institute of Technology & Research, Indore
DBMS Lab 5 – Join Queries
Joint Multiple Table (Equi Join):
Sometimes we require to treat more than one table as though manipulate data from all the tables
as though the tables were not separate object but one single entity. To achieve this we have to
join tables. Tables are joined on column that has dame data type and data within tables.
The tables that have to be joined are specified in the FROM clause and the joining attributes in
the WHERE clause.

Algorithm for JOIN in SQL:


1. Cartesian product of tables (specified in the FROM clause)
2. Selection of rows that match (predicate in the WHERE clause)
3. Project column specified in the SELECT clause.

Cartesian product:-
A Cartesian join is a join of every row of one table to every row of another table. This normally
happens when no matching join columns are specified. For example, if table A with 100 rows is
joined with table B with 1000 rows, a Cartesian join will return 100,000 rows. Something to be
avoided
Syntax: Join tables SAILORS and RESERVES on the basis of SID through Cartesian product.
Select columnname from tablename1 cross join tablename 2 where (search condition);
Example:
SQL> SELECT S.SID, S.SNAME FROM SAILORS S CROSS JOIN RESERVES R WHERE (S.SID=R.SID);

INNER JOIN:
An equi join (inner join or simple join) is a join statement that uses an equivalence operation
(i.e: colA = colB) to match rows from different tables. The converse of an equi join is a nonequi
join operation.
Syntax:
Select columnname from tablename1 inner join tablename 2 where (search condition);
Example: Join tables SAILORS and RESERVES on the basis of SID through Inner Join.
SQL> SELECT S.SID, S.SNAME FROM SAILORS S INNER JOIN RESERVES R WHERE (S.SID=R.SID);

LEFT OUTER JOIN:


LEFT OUTER JOIN = Cartesian product + selection but include rows from the left table which are
unmatched pat nulls in the values of attributes belonging to the second table
Syntax:
Select columnname from tablename1 left outer join tablename 2 where (search condition);
Example: Join tables SAILORS and RESERVES on the basis of SID through Left Outer Join.
SQL> SELECT S.SID, S.SNAME FROM SAILORS S LEFT OUTER JOIN RESERVES R WHERE
(S.SID=R.SID);

DBMS Lab Manual 31


Acropolis Institute of Technology & Research, Indore
RIGHT OUTER JOIN:
RIGHT OUTER JOIN = Cartesian product + selection but include rows from right table which are
unmatched
Syntax:
Select columnname from tablename1 right outer join tablename 2 where (search condition);

Example: Join tables SAILORS and RESERVES on the basis of SID through Right Outer Join.
SQL> SELECT S.SID, S.SNAME FROM SAILORS S RIGHT OUTER JOIN RESERVES R WHERE
(S.SID=R.SID);

FULL OUTER JOIN


Syntax:
Select columnname from tablename1 full outer join tablename 2 where (search condition);
Example: Join tables SAILORS and RESERVES on the basis of SID through Full Outer Join.
SQL> SELECT S.SID, S.SNAME FROM SAILORS S FULL OUTER JOIN RESERVES R WHERE
(S.SID=R.SID);

DBMS Lab Manual 32


Acropolis Institute of Technology & Research, Indore
ASSIGNMENT NO.5
Exercise on Joins and Correlation:

a. Find out the products which have been sold to ‘Ivan Bayross’.
b. Find out the products and their quantities that have to be delivered in the current month.
c. List the product no. and the description of constantly sold (i.e. rapidly moving) products.
d. Find the names of clients who have purchased ‘Trousers’.
e. List the products and orders from customers who have ordered less than 5 units of ‘Pull
Overs’.
f. Find the product and their quantities for the orders placed by ‘Ivan Bayross’ and ‘Mamta
Mazumdar’.
g. Find the product and their quantities for the orders placed by client no. ‘C00001’ and
‘C00002’.

DBMS Lab Manual 33


Acropolis Institute of Technology & Research, Indore
DBMS Lab 6 – Views, Synonyms, Indexes and Sequences
VIEWS
Logical data is how we want to see the current data in our database. Physical data is how this
data is actually placed in our database. Views are masks placed upon tables. This allows the
programmer to develop a method via which we can display predetermined data to users
according to our desire or his requirement. If we do any operation on view, in background they
are performed on the base table using which they are built. There are some constraints on DML
operation performed if the view is created using multiple tables. Also if any DML operation violets
any constraint of base table then that operation can not be performed.
Views may be created for the following reasons:
1. The DBA stores the views as a definition only. Hence there is no duplication of data.
2. Simplifies Queries.
3. Can be queried as a base table itself.
4. Provides data security.
5. Avoids data redundancy.

Creation of Views:-
Syntax:-
CREATE VIEW viewname AS
SELECT columnname,columnname
FROM tablename
WHERE columnname=expression_list;
Example: -
Create a view for Expert Sailors (A sailor is an Expert Sailor if his rating is more than 7).
SQL> CREATE VIEW EXPERTSAILOR AS SELECT SID, SNAME, RATING FROM SAILORS WHERE
RATING > 7;
Now on this view we can use normal SQL statements as we are using on Base tables.
Ex: - Find average age of Expert sailors.
SQL> SELECT AVG (AGE) FROM EXPERTSAILOR;
Write the following queries on Expert Sailor View.
1) Find the Sailors with age > 25 and rating equal to 10.
2) Find the total number of Sailors in Expert Sailor view.
3) Find the number of Sailors at each rating level (8, 9, 10).
4) Find the sum of rating of Sailors.
5) Find the age of Oldest as well as Youngest Expert Sailor.
If we decide that we no longer need a view and want to destroy it (i.e. removing the definition
of view) we can drop the view. A view can be dropped using the DROP VIEW command.

To drop the ExpertSailor view.


Syntax:-
DROP VIEW viewname;
Example:-
SQL> DROP VIEW EXPERTSAILOR;
DBMS Lab Manual 34
Acropolis Institute of Technology & Research, Indore
Indexes
An index is an ordered list of content of a column or group of columns in a table.
An index created on the single column of the table is called simple index. When multiple table
columns are included in the index it is called composite index.

Creating an Index for a table:-


Syntax (Simple)
CREATE INDEX index_name
ON tablename(column name);
Example:
CREATE INDEX VERI_SID ON SAILORS (SID);

Composite Index:-
Syntax:-
CREATE INDEX index_name
ON tablename(columnname,columnname);
Example:
CREATE INDEX VERI_SID ON SAILORS (SID,AGE);

Creating a UniQuestion Index:-


Syntax:-
CREATE UNIQUESTION INDEX indexfilename
ON tablename(columnname);
Example:
CREATE INDEX VERI_SID ON SAILORS (SID);

Dropping Indexes:-
An index can be dropped by using DROP INDEX
SYNTAX:-
DROP INDEX indexfilename;
Example:-
DROP INDEX VERI_SID;

Type of Index

DBMS Lab Manual 35


Acropolis Institute of Technology & Research, Indore
Sequences
The quickest way to retrieve data from a table is to have a column in the table whose data
uniquely identifies a row. By using this column and a specific value, in the WHERE condition of a
SELECT sentence the oracle engine will be able to identify and retrieve the row fastest.
To achieve this, a constraint is attached to a specific column in the table that ensures that the
column is never left empty and that the data values in the column are unique. Since human
beings do data entry, it is quite likely that a duplicate value could be entered, which violates this
constraint and the entire row is rejected.
If the value entered into this column is computer generated it will always fulfill the unique
constraint and the row will always be accepted for storage.
Oracle provides an object called sequence that can generate numeric values. The value generated
can have a maximum of 38 digits. A sequence can be defined to:
• Generate numbers in ascending or descending order.
• Provide intervals between numbers.
• Caching of sequence numbers in memory to speed up their availability.
A sequence is an independent object and can be used with any table that requires its output.

Creating Sequences
The minimum information required for generating numbers using a sequence is:
• The starting number
• The maximum number that can be generated by a sequence.
• The increment value that can be generating the next number.
This information is provided to Oracle at the time of sequence creation.
Syntax:
create sequence <sequence-name> [increment by <integer value> start with <integer value>
maxvalue <integer value>/nomaxvalue minvalue <integer value>/nominvalue cycle/nocycle cache
<integer value>/nocache order/noorder ]

Example:

CURRVAL and NEXTVAL

DBMS Lab Manual 36


Acropolis Institute of Technology & Research, Indore
ASSIGNMENT NO. 6
Write appropriate SQL statements for the following:

a. Create a simple index idx_prod on product cost price from the product_master table.
b. Create a sequence inv_seq with the following parameters, increment by 3, cycle, cache 4
and which will generate the numbers from 1 to 9999 in ascending order.
c. Create a view on order no., orderdate, orderstatus of sales_order table and productno.,
productrate and qtyordered of sales_order_details.

DBMS Lab Manual 37


Acropolis Institute of Technology & Research, Indore
DBMS Lab 7 – TCL and DCL
AIM: To implement TCL statements.
THEORY:
A transaction begins with the first executable SQL statement after a connection made to the
Oracle engine. All changes made to an Oracle table data via unit a transaction are made or
undone at one instance. Transaction Control Language (TCL) consists of various commands as
follows
• COMMIT
• ROLLBACK
• SAVEPOINT

SAVEPOINT:
SAVEPOINT marks and saves current point in the processing of a transaction. When a SAVEPOINT
is used with a ROLLBACK statement, parts of a transaction can be undone.
An active savepoint is the one that is specified since the last COMMIT or ROLLBACK.
Syntax:
SAVEPOINT savepointname;

COMMIT:
A commit ends the current transaction and makes permanent any changes made during the
transactions. A commit will also release any existing savepoint that may be in use.
Syntax:
COMMIT;

ROLLBACK:
A ROLLBACK does exactly the opposite of COMMIT. It ends the transaction but undoes any
changes made during the transaction.
Syntax:
ROLLBACK TO [SAVEPOINT] savepointname;
Where SAVEPOINT: is optional and is used to rollback a partial transaction, as far the specified
savepoint. Savepointname: is a savepoint created in current transaction.
ROLLBACK can be performed with or without the SAVEPOINT clause. The implication of each is
described below:
A ROLLBACK operation performed without the SAVEPONT clause amounts to the following:
• Ends the transaction.
• Undoes all the changes in the current transaction.
• Erases all savepoints in that transaction.
A ROLLBACK operation performed with the TO SAVEPOINT clause amounts to the following:
• A predetermined portion of the transaction is rolled back.
• Retains the savepoint rolled back to, but losses those create after the named savepoint.
Conclusion: TCL statements are used to save or erase changes made in the database during
current transaction.

DBMS Lab Manual 38


Acropolis Institute of Technology & Research, Indore
AIM: To implement DCL statements.
THEORY:
Data Control Language (DCL) consists of various commands which are related to data sharing and
security of data in database. They are
• GRANT
• REVOKE

Granting Privileges:
Objects that are created by a user are owned and controlled by that user. If user wishes to access
any of the objects belonging to another user, the owner of the object will have to give
permissions for such access. This is called Granting of Privileges.
Granting privileges using the GRANT statements:
The GRANT statements provide various types of access to database objects such as tables, views.
Syntax:
GRANT {object privileges}
ON object name
TO username;
Example:
If we want to give the user Rajesh all data manipulation permissions on the table SAILORS then,
GRANT ALL ON SAILORS TO RAJESH;
Or
GRANT SELECT, UPDATE ON SAILORS TO RAVI;

Object Privileges:
Each object privilege that is granted authorizes the grantee to perform some operation on the
object. The user can grant all the privileges or grant only specific object privileges.
The list of object privileges is as follows:
• ALTER: allows the grantee to change the table definitions with the ALTER table command.
• DELETE: allows the grantee to remove the records from the table with the DELETE command.
• INDEX: allows the grantee to create an index on the table with the CREATE INDEX command.
• INSERT: allows the grantee to add records to the table with the INSERT command.
• SELECT: allows the grantee to query the table with SELECT command.
• UPDATE: allows the grantee to modify the records in the table with the UPDATE command.

Revoking privileges given:


Privileges once given can be denied to a user using the REVOKE command. The object owner can
revoke privileges granted to another user. A user of an object who is not owner, but has been
granted the GRANT privilege, has the power to REVOKE the privileges from the grantee.
Revoking permission using the REVOKE statement:
The REVOKE statement is used to deny the grant given on an object.
Syntax:
REVOKE {object privileges}
ON object name
FROM username;
DBMS Lab Manual 39
Acropolis Institute of Technology & Research, Indore
Example:
REVOKE ALL ON SAILORS FROM RAJESH;
Or
REVOKE SELECT, UPDATE ON SAILORS FROM RAVI;
The REVOKE command is used to revoke object privileges that the user previously granted to the
Revoke.
The REVOKE command cannot be used to revoke the privileges granted through operating
system.

Conclusion:
DCL statements are used to provide data sharing of data in database.

DBMS Lab Manual 40


Acropolis Institute of Technology & Research, Indore
ASSINGNMENT NO. 7
Exercise on DCL statements:
a. Give the user Ivan permission only to view records in the tables sales_order and
sales_order_details along with option to further grant permission on these tables to other
users.
b. Give the user Ivan all data manipulation privileges on the table client_master without an
option to further grant permission on client_master table to other users.
c. Take back all privileges given to the user Ivan on the table client_master.

Exercise on TCL statements:


a. A factory maintains records of stocks_on_hand and material requirements in item_master
table and item_requisite table respectively.

Table Name: item_master


Column Name Data Type Size Default Attributes
item_id Number 4 Primary key, identify number for the item
Description Varchar2 20 Item description
Bal_stock Number 3 Balance stock for an item

Data for item_master table:


Item_id Description Bal_stock
102 Aluminium sheets 120
105 Steel sheets 96
151 A14 Iron rods 50
209 A14 Hexagonal nut 334
254 A14 steel bolts 250
303 Tar Washers 500

Table Name: item_requisite


Column Name Data type Size Default Attributes
item_id Number 4 Identity number for the item requested
dept_code Number 2 Code for department placing the requisite
Quantity Number 3 Quantity of items requested

Data for item_requisite table:


Item_id dept_code Bal_stock
102 10 50
102 20 50
105 10 50
105 20 25
DBMS Lab Manual 41
Acropolis Institute of Technology & Research, Indore
151 10 30
151 20 30
209 10 300
303 20 400

Exercise
a. Update the bal_stock in the item_master table for each requiosite in the item_requisite
table. Based on the item_id, decrease the bal_stock in the item_master table by the
quantity in the item_requisite table. The update operation is completed only when the
corresponding record in the item_requisite table is deleted.

DBMS Lab Manual 42


Acropolis Institute of Technology & Research, Indore
DBMS Lab 8 – PL/SQL
PL/SQL Introduction –
PL/SQL bridges the gap between database technology and procedural programming languages. It
can be thought of as a development tool that extends the facilities of Oracles SQL database
language. Via PL/SQL you can insert, delete, update and retrieve table data as well as writing
loops or branching to another block of code.
PL/SQL stands for "Procedural Language extensions to SQL", and can be used in Oracle databases.
PL/SQL is closely integrated into the SQL language, yet it adds programming constructs that are
not native to SQL.

Advantages of PL/SQL
1. PL/SQL supports not only SQL data manipulation but also provides facilities of conditional
checking, branching and looping.
2. PL/SQL sends an entire block of statements to the Oracle engine at one time.
3. PL/SQL permits dealing with errors and displaying user friendly messages when the error
occurs.
4. Via PL/SQL all sorts of calculations can be done quickly without the use of Oracle Engine
5. Applications written in PL/SQL are portable to any computer hardware and operating system
where Oracle is operational.

The different sections of PL/SQL block are as follows:

DECLARE SECTION
Declarations of memory variables, constants, cursors etc in PL/SQL
BEGIN
SQL executable statements
PL/SQL executable statements
EXCEPTION
SQL or PL/SQL code to handle errors that may arise during the execution of the code block

PL/SQL Block structure-


DECLARE
Declarations of memory variables used later
BEGIN
SQL executable statements for manipulating table data.
EXCEPTIONS
SQL and/or PL.SQL code to handle errors.
END;
Example:
Write a PL/SQL block of code for inverting a number from 5639 to 9365.
DECLARE
/* Declaration of memory variables and constants to be in the execution section. */
DBMS Lab Manual 43
Acropolis Institute of Technology & Research, Indore
Given_No. VARCHAR (5) :=’5639’;
Str_Length NUMBER (2);
Inverted_N0. VARCHAR (5);
BEGIN
Str_Length := length (given_No.);
FOR cntr IN REVERSE 1 .......... Str_Length
LOOP
Inverted_No. := Inverted_No.||substr (Given_No., cntr,1);
END LOOP;
dbms_output.put_line(‘The Given No. is’ ||Given_No.);
dbms_output.put_line(‘The Inverted No. is’ ||Inverted_No.);
END;
Output:
The Given No. is 5639
The Inverted No. is 9365

Displaying user Messages on the screen –


Any programming tool requires a method through which messages can be displayed to the user.

dbms_output is a package that includes a number of procedure and functions that accumulate
information in a buffer so that it can be retrieved later. These functions can also be used to
display message to the user.

put_line: put a piece of information in the buffer followed by a end of line marker. It can also be
used to display message to the user.
Setting the server output on:

SET SERVER OUTPUT ON:


Example: Write the following code in the PL/SQL block to display message to user
DBMS_OUTPUT.PUT_LINE (‘Display user message’);

Conditional control in PL/SQL


Syntax:
IF <condition> THEN
<Action>
ELSEIF<condition>
<Action>
ELSE
<Action>
ENDIF;

DBMS Lab Manual 44


Acropolis Institute of Technology & Research, Indore
The WHILE LOOP:
Syntax:
WHILE <condition>
LOOP
<Action>
END LOOP;

The FOR LOOP statement:


Syntax:
FOR variable IN [REVERSE] start—end
LOOP
<Action>
END LOOP;

The GOTO statement:


The goto statement allows you to change the flow of control within a PL/SQL Block.

Cursor-
We have seen how oracle executes an SQL statement. Oracle DBA uses a work area for its internal
processing. This work area is private to SQL’s operation and is called a cursor.
The data that is stored in the cursor is called the Active Data set. The size of the cursor in
memory is the size required to hold the number of rows in the Active Data Set.

Explicit Cursor-
You can explicitly declare a cursor to process the rows individually.
A cursor declared by the user is called Explicit Cursor. For Queries that return more than one row,
you must declare a cursor explicitly.
The data that is stored in the cursor is called the Active Data set. The size of the cursor in
memory is the size required to hold the number of rows in the Active

Why use an Explicit Cursor-


Cursor can be used when the user wants to process data one row at a time.

Explicit Cursor Management-


The steps involved in declaring a cursor and manipulating data in the active data set are:-
• Declare a cursor that specifies the SQL select statement that you want to process.
• Open the Cursor.
• Fetch the data from the cursor one row at a time.
• Close the cursor.

DBMS Lab Manual 45


Acropolis Institute of Technology & Research, Indore
Explicit Cursor Attributes-
Oracle provides certain attributes/ cursor variables to control the execution of the cursor.
Whenever any cursor(explicit or implicit) is opened and used Oracle creates a set of four system
variables via which Oracle keeps track of the ‘Current’ status of the cursor. You
• Declare a cursor that specifies the SQL select statement that you want to process.
• Open the Cursor.
• Fetch the data from the cursor one row at a time.
• Close the cursor.
Both the types of Cursors have following General attributes.
Attribute Name Description
%ISOPEN returns true if cursor is open, false otherwise
%FOUND returns true if record was fetched successfully, false otherwise.
%NOTFOUND returns true if record was not fetched successfully, false otherwise.
%ROWCOUNT returns number of records processed from the cursor.
The commands used to control the cursor are DECLARE, OPEN, FETCH and CLOSE.

Oracle/PLSQL: Declare a Cursor


A cursor is a SELECT statement that is defined within the declaration section of your PL/SQL code.
We'll take a look at three different syntaxes for cursors.

How to Declare the Cursor:-


Syntax:-
Cursor <Cursorname> is Sql Statement;
Example:
Here we are going to create a cursor that will keep track of SAILOR Details from SAILORS and
RESERVES
SQL> CURSOR CRSR_SID IS
SELECT SID, SNAME, AGE FROM SAILORS WHERE SID IN (SELECT SID FROM RESERVES GROUPBY
SID);
/* Declaration of memory variables that holds data fetched from cursor*/
Str_SID SAILORS.SID %type;
Str_SNMAE SAILORS.SNAME %type;
Str_AGE SAILORS.AGE %type;

How to Open the Cursor:-


Syntax:-
Open Cursorname;
Example:
OPEN CRSR_SID;

Fetching a record From the Cursor:-


The fetch statement retrieves the rows from the active set to the variables one at a time.
Each time a fetch is executed. The focus of the DBA cursor advances to the next row in the Active
set.

DBMS Lab Manual 46


Acropolis Institute of Technology & Research, Indore
One can make use of any loop structure (Loop-End Loop along with While, for) to fetch the
records from the cursor into variable one row at a time.

Syntax:-
Fetch cursorname into variable1, variable2,……………………..
Example:
FETCH CRSR_SID INTO Str_SID, Str_SNAME, Str_AGE;
Closing a Cursor:-
Syntax:-
Close <cursorname>;
Example:
Close CRSR_SID;

DBMS Lab Manual 47


Acropolis Institute of Technology & Research, Indore
ASSINGNMENT NO. 8
On the basis of table created in previous exercise. Write a PL/SQL block of code based on
conditions:

a. If at any given point, the value in bal_stock becomes negative, the entire update operation
for all item_id should rollback.
b. If at any given point, the value in bal_stock becomes negative, the update operation for
that particular item_id should rollback.
c. Create user defined Exceptions. Write a program, if the requested qty attempted is more
than the current balance qty held for a item, a user defined exception is raised displaying
an appropriate error message otherwise perform the appropriate task.

DBMS Lab Manual 48


Acropolis Institute of Technology & Research, Indore

DBMS Lab 9 – Procedure and Functions


AIM: To Implement Procedures
THEORY:
Procedure is a subprogram used to perform a specific action. A subprogram is a named block of
PL/SQL. There are two types of subprograms in PL/SQL namely Procedures and Functions. Every
subprogram will have a declarative part, an executable part or body, and an exception handling
part, which is optional. Declarative part contains variable declarations. Body of a subprogram
contains executable statements of SQL and PL/SQL.
Statements to handle exceptions are written in exception part.
Procedure specification begins with CREATE and ends with procedure name or parameters list.
Procedures that do not take parameters are written without a parenthesis. The body of the
procedure starts after the keyword IS or AS and ends with keyword END.

Syntax for Procedure:


CREATE [OR REPLACE] PROCEDURE procedure_name
[(parameter_name [IN | OUT | IN OUT] type [, ...])]
{IS | AS}
BEGIN
procedure_body
EXCEPTION
Exception handling
END procedure_name;

Example:
Here we are going to create a procedure that will check the rating of SAILOR

CREATE OR REPLACE PROCEDURE CHECK_RATING (VRATING IN NUMBER)


IS
DummyRATING NUMBER (5);
BEGIN
SELECT DISTINCT RATING INTO dummyRATING from SAILORS WHERE RATING=VRATING;
DBMS_OUTPUT.PUT_LINE(“Rating is OK”);
EXCEPTION
WHEN_NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE(“Rating is NOT OK”);
END CHECK_RATING;

Procedure is created using CREATE PROCEDURE statement.


OR REPLACE specifies the procedure is to replace an existing procedure if present. One can use
this option to modify an existing procedure.

DBMS Lab Manual 49


Acropolis Institute of Technology & Research, Indore
A procedure may be passed multiple parameters. IN | OUT | IN OUT specifies the mode of the
parameter. Type specifies the datatype of the parameter.
IN - The parameter can be referenced by the procedure or function. The value of the parameter
cannot be overwritten by the procedure or function.
OUT - The parameter cannot be referenced by the procedure or function, but the value of the
parameter can be overwritten by the procedure or function.
IN OUT - The parameter can be referenced by the procedure or function and the value of the
parameter can be overwritten by the procedure or function.
Procedure body contains the SQL and PL/SQL statements to perform the procedure's task.

Exception Section:
The Exception section of a PL/SQL Block starts with the reserved keyword EXCEPTION. This
section is optional. Any errors in the program can be handled in this section, so that the PL/SQL
Blocks terminates gracefully. If the PL/SQL Block contains exceptions that cannot be handled, the
Block terminates abruptly with errors.

Advantages:
When client executes a procedure or a function, the processing is done in the server.
Server is likely to me more powerful than the clients which in turn mean that stored procedures
should run faster. This reduces network traffic.
As the procedures/functions are stored in the Oracle database there is no need to transfer the
code from the clients to the database server or to transfer intermediate results from the server to
the clients. This results in much less network traffic and again improves scalability
The subprograms are compiled and stored in the Oracle database as stored programs and can be
invoked whenever required. As they are stored in compiled form when called, they only need to
be executed. Hence they save time needed for compilation. They allow breaking the program into
manageable modules. They provide reusability and maintainability for the code.

Disadvantages:
There is an overhead involved in embedding or calling PL/SQL procedures from SQL in Oracle due
to the context switching that the Oracle database has to perform. This may be significant in terms
of performance but usually this overhead is outweighed by performance advantages of using
PL/SQL.
More memory may be required on the Oracle database server when using Oracle
PL/SQL packages as the whole package is loaded into memory as soon as any object in the
package is accessed

Conclusion:
Stored procedures should be used to improve the performance and scalability of applications.
The disadvantages are easily outweighed by the advantages and the use of packages to combine
related objects (procedures, functions and variables) into one physical unit enhances these
advantages.

DBMS Lab Manual 50


Acropolis Institute of Technology & Research, Indore
AIM: To Implement Function
THEORY:
A function is a named PL/SQL Block which is similar to a procedure. The major difference between
a procedure and a function is, a function must always return a value, but a procedure may or may
not return a value.

Syntax for Function:


CREATE [OR REPLACE] FUNCTION function_name [parameters] RETURN
return_datatype;
IS
Declaration_section
BEGIN
Execution_section
Return return_variable;
EXCEPTION
exception section
Return return_variable;
END;

Example:
Here we are going to create a function that will check the rating of SAILOR

CREATE OR REPLACE FUNCTION CHECK_RATING (VRATING IN NUMBER)


RETURN NUMBER IS
DummyRATING NUMBER (5);
BEGIN
SELECT DISTINCT RATING INTO dummyRATING from SAILORS WHERE RATING=VRATING;
RETURN 1;
EXCEPTION
WHEN NO_DATA_FOUND THEN RETURN 0;
END;

Return Type: The header section defines the return type of the function. The return datatype can
be any of the oracle datatype like varchar, number etc.
The execution and exception section both should return a value which is of the datatype defined
in the header section.

Conclusion:
Functions are PL/SQL stored programming units, providing a way to hide implementation details
in a programming unit. Functions can be used as right operands in PL/SQL and be called from SQL
statements, while procedures cannot

DBMS Lab Manual 51


Acropolis Institute of Technology & Research, Indore
Advantages:
When client executes a procedure or a function, the processing is done in the server. Server is
likely to me more powerful than the clients which in turn mean that stored procedures should run
faster. This reduces network traffic.

As the procedures/functions are stored in the Oracle database there is no need to transfer the
code from the clients to the database server or to transfer intermediate results from the server to
the clients. This results in much less network traffic and again improves scalability.

The subprograms are compiled and stored in the Oracle database as stored programs and can be
invoked whenever required. As they are stored in compiled form when called, they only need to
be executed. Hence they save time needed for compilation. They allow breaking the program into
manageable modules. They provide reusability and maintainability for the code.

Disadvantages:
There is an overhead involved in embedding or calling PL/SQL procedures from SQL in Oracle due
to the context switching that the Oracle database has to perform. This may be significant in terms
of performance but usually this overhead is outweighed by performance advantages of using
PL/SQL.

More memory may be required on the Oracle database server when using Oracle PL/SQL
packages as the whole package is loaded into memory as soon as any object in the package is
accessed

Conclusion:
Stored procedures should be used to improve the performance and scalability of applications. The
disadvantages are easily outweighed by the advantages and the use of packages to combine
related objects (procedures, functions and variables) into one physical unit enhances these
advantages.

DBMS Lab Manual 52


Acropolis Institute of Technology & Research, Indore
ASSINGNMENT NO. 9
Exercise on PL/SQL procedures and functions.

a. Create a procedure that accepts a client_no. and checks if the client_no. exists in the table
client_master. If the client_no. exists, display a message “Valid Client” and if the client_no.
does not exist than display an appropriate error message.
b. Drop the above created procedure.
c. Create a function getMaxClientNo that returns MAX value for client_no. in the table
client_master. Using this function write an insert statement to add a new record in
client_master table.
d. Create a package named mypackage that will hold the function and procedure created
above. Write down the package specification and package body for the package
mypackage.

DBMS Lab Manual 53


Acropolis Institute of Technology & Research, Indore
DBMS Lab 10 – Triggers
How to apply Database Triggers:-
A database triggers is stored PL/SQL program unit associated with a specific database table or
view. The code in the trigger defines the action the database needs to perform whenever some
database manipulation (INSERT, UPDATE, and DELETE) takes place.
Unlike the stored procedure and functions, which have to be called explicitly, the database
triggers are fired (executed) or called implicitly whenever the table is affected by any of the above
said DML operations. Till oracle 7.0 only 12 triggers could be associated with a given table, but in
higher versions of Oracle there is no such limitation. A database trigger fires with the privileges of
owner not that of user
A trigger has three basic parts:-
1. A triggering event or statement.
2. A trigger restriction
3. A trigger action.
A triggering event can be an insert, update, or delete statement or a instance shutdown or
startup etc. The trigger fires automatically when any of these events occur on the specified table
or a view. A trigger constraint specifies a Boolean expression that must be true for the trigger to
fire. This condition is specified using the WHEN clause. The trigger action is a procedure that
contains the code to be executed when the trigger fires.

Use of Database Triggers:-


Database triggers support Oracle to provide a highly customized database management system.
Some of the uses to which the database triggers can be put to customize management
information in Oracle are as follows:-
• A Trigger can permit DML statements against a table any if they are issued, during regular
business hours or on predetermined weekdays.
• A trigger can also be used to keep an audit trail of a table along with the operation
performed and the time on which the operation was performed.
• It can be used to prevent invalid transactions.
• Enforce complex security authorizations.

Types of Triggers:-
Using the various options, four types of triggers can be created:-
1. Before Statement Trigger: - Before executing the triggering statement, the trigger action is
executed.
2. Before Row Trigger: - Before modifying the each row affected by the triggering statement and
before appropriate integrity constraints, the trigger is executed if the trigger restriction either
evaluated to TRUE or was not included.’
3. After Statement Trigger: - After executing the triggering statement and applying any deferred
integrity constraints, the trigger action is executed.

DBMS Lab Manual 54


Acropolis Institute of Technology & Research, Indore
4. After row Trigger: - After modifying each row affected by the triggering statement and possibly
applying appropriate integrity constraints, the trigger action is executed for the current row if the
trigger restriction either evaluates to TRUE or was not included.

Syntax For Creating Trigger:-


Create or replace Trigger<Triggername> {Before,After} {Delete, Insert, Update } On
<Tablename> For Each row when Condition
Declare
<Variable declarations>;
<Constant Declarations>;
Begin
<PL/SQL> Subprogram Body;
Exception
Exception PL/SQL block;
End;

Example:
Create a trigger that will fired when an update or delete operation is performed on the table
SAILORS. The trigger first check for the operation being performed on the table. Then depending
on the operation being performed, a variable is assigned the value Update or Delete. Previous
values of the modified record of the table SAILORS are inserted into the SAILORS_NEW table.
For that we have to create SAILORS_NEW table first.

To create SAILORS_NEW:
SQL>CREATE TABLE SAILORS_NEW (SID NUMBER(5),SNAME VARCHAR2(30),RATING
NUMBER(5),AGE NUMBER(4,2));
To create Trigger SAILORS_TRAIL
SQL> CREATE TRIGGER SAILORS_TRAIL AFTER UPDATE OR DELETE ON SAILORS
DECLARE
OPER VARCHAR2(8);
BEGIN
IF Updating THAN
OPER =’UPDATE’;
END IF;
IF Deleting THEN
OPER = ‘DELETE’;
END IF;
INSERT INTO SAILORS_NEW VALUES (:OLD.SID, :OLD.SNAME, :OLD.RATING, :OLD.AGE);
END;

OUTPUT
Trigger Created.

DBMS Lab Manual 55


Acropolis Institute of Technology & Research, Indore
Restrictions:
• One cannot create a BEFORE trigger on a view.
• One can update the: NEW values.
• One cannot update the: OLD values.

Drop a Trigger
Syntax:-
DROP TRIGGER trigger_name;
Example:
DROP TRIGGER SAILORS_TRAIL;

Disable a Trigger
Syntax:-
ALTER TRIGGER trigger_name DISABLE;
Example:
ALTER TRIGGER SAILORS_TRAIL DISABLE;

Enable a Trigger
Syntax:-
ALTER TRIGGER trigger_name ENABLE;
Example:
ALTER TRIGGER SAILORS_TRAIL DISABLE;

DBMS Lab Manual 56


Acropolis Institute of Technology & Research, Indore
ASSINGNMENT NO. 10
Exercise on Triggers:

a. Write and update trigger on client_master table. The system should keep track of the
records that are being updated. The old values of the updated record should be added in
the audit_trail table.

Table name: audit_trail

Column name Datatype Size Default Attributes


Client_no. Varchar2 6
Name Varchar2 20
Bal_due Number 10,2
Operation Varchar2 8
Userid Varchar2 20
Odate Date

b. Write a trigger on delete of client_master table to keep the details of deleted client in
old_client_master table.
c. Write a trigger on update of client_master table and check if client_no is changing then it
should stop operation and give error message.
d. Write a trigger that limits the DML actions to the client_master table to weekdays from
8.30am to 6.30pm. If a user tries to insert/update/delete a row in the client_master table,
a warning message will be prompted.
e. Disable the trigger created in above exercise.
f. Delete the trigger created in above exercise.

DBMS Lab Manual 57


Acropolis Institute of Technology & Research, Indore
LIBRARY MANAGEMENT SYSTEM
Aim:
To develop a package for a library management system
Procedure:
1. Create the table for books.
2. Create the table for students.
3. Create the table for lending books.
4. Create the procedure for lending books
5. Create the procedure for returning books and simultaneously removing from lending table.

Output:
SQL> create table books(book_no varchar2(6),book_name varchar2(35),book_author
varchar2(20));
Table created.
SQL> desc books;
Name Null? Type

BOOK_NO VARCHAR2(6)
BOOK_NAME VARCHAR2(35)
BOOK_AUTHOR VARCHAR2(20)

SQL> create table students(reg_no varchar2(12),stu_name varchar2(25),dept varchar2(4),batch


varchar2(9));
Table created.
SQL> desc students;
Name Null? Type

REG_NO VARCHAR2(12)
STU_NAME VARCHAR2(25)
DEPT VARCHAR2(4)
BATCH VARCHAR2(9)

SQL> insert into books values('cse1','Programming in C','Balagurusamy');


1 row created.
SQL> insert into books values('cse2','Programming in C','Balagurusamy');
1 row created.
SQL> insert into books values('cse3','The Complete Reference-Java','Patrik Nort
1 row created.
SQL> insert into books values('ece1','Eletron Devices','Ravi Kumar');
1 row created.
SQL> insert into books values('ece2','Communication
Enginnering','dheraj shah');
1 row created.

DBMS Lab Manual 58


Acropolis Institute of Technology & Research, Indore
SQL> insert into books values('ece3','Communication Enginnering','Dheraj Shah');
1 row created.
SQL> select * from books;
BOOK_N BOOK_NAME BOOK_AUTHOR

cse1 Programming in C Balagurusamy


cse2 Programming in C Balagurusamy
cse3 The Complete Reference-Java Patrik Norton
ece1 Eletron Devices Ravi Kumar
ece2 Communication Enginnering dheraj shah
ece3 Communication Enginnering dheraj shah
6 rows selected.

SQL> insert into students values('8080410910','Ajay','CSE','2005-2009');


1 row created.
SQL> insert into students values('8080410911','Banu','CSE','2004-2008');
1 row created.
SQL> insert into students values('8080510911','Sreeja','ECE','2004-2008');
1 row created.SQL> insert into students values('8080510910','Ram','ECE','2005-
2009');
1 row created.
SQL> select * from students;
REG_NO STU_NAME DEPT BATCH

8080410910 Ajay CSE 2005-2009


8080410911 Banu CSE 2004-2008
8080510911 Sreeja ECE 2004-2008
8080510910 Ram ECE 2005-2009
4 rows selected.

SQL> create table lending(reg_no varchar2(12),stu_name varchar2(25),book_no


varchar2(6),book_name varchar2(35), ddate date);
Table created.

SQL> desc lending;


Name Null? Type

REG_NO VARCHAR2(12)
STU_NAME VARCHAR2(25)
BOOK_NO VARCHAR2(6)
BOOK_NAME VARCHAR2(35)
DDATE DATE

DBMS Lab Manual 59


Acropolis Institute of Technology & Research, Indore
sql>create procedure lend(x1 varchar, x2 varchar)as
2 reg varchar2(12);
3 bno varchar2(6);
4 sname varchar2(25);
5 bname varchar2(35);
6 begin
7 reg:=x1;
8 bno:=x2;
9 select stu_name into sname from students where reg_no = reg;
10 if SQL%FOUND Then
11 select book_name into bname from books where book_no = bno;
12 if SQL%FOUND Then
13 insert into lending values(reg,sname,bno,bname,sysdate);
14 dbms_output.put_line('Record updated successfully');
15 else
16 dbms_output.put_line('No book found');
17 end if;
18 else
19 dbms_output.put_line('No student found');
20 end if;
21 end;
Procedure created.

SQL> exec lend('8080410910','cse1');


PL/SQL procedure successfully completed.

SQL> select * from lending;


REG_NO STU_NAME BOOK_N BOOK_NAME DDATE

8080410910 Ajay cse1 Programming in C 01-OCT-06

SQL> create table returning(reg_no varchar2(12),stu_name varchar2(35), ddate date,rdate date);


Table created.

SQL> desc returning;


Name Null? Type

REG_NO VARCHAR2(12)
STU_NAME VARCHAR2(25)
BOOK_NO VARCHAR2(6)
BOOK_NAME VARCHAR2(35)
DDATE DATE
RDATE DATE

DBMS Lab Manual 60


Acropolis Institute of Technology & Research, Indore
sql>create procedure returns(x1 varchar)as
2 bno varchar2(6);
3 reg varchar2(12);
4 sname varchar2(25);
5 bname varchar2(35);
6 deldate date;
7 begin
8 bno:=x1;
9 select reg_no ,stu_name ,book_name ,ddate into
10 reg,sname,bname,deldate from lending where book_no = bno;
11 if SQL%FOUND Then
12 insert into returning values(reg, sname,bno,bname,deldate,sysdate);
13 delete from lending where book_no=bno;
14 else
15 dbms_output.put_line('No book found');
16 end if;
17 end;
/
Procedure created.

SQL> exec returns('cse1');


PL/SQL procedure successfully completed.
SQL> select * from lending;
no rows selected
SQL> select * from returning;
REG_NO STU_NAME BOOK_N BOOK_NAME DDATE RDATE

8080410910 Ajay cse1 Programming in C 01-OCT-06 01-OCT-06

Result :
Thus the procedure for library management system was written and executed.

DBMS Lab Manual 61


Acropolis Institute of Technology & Research, Indore
BANKING MANAGEMENT SYSTEM
Aim:
To develop the package for the bank management system.

Procedure:
1. Create the table for customer.
2. Create the table for transaction.
3. Insert the values in the bankmaster table using procedure.
4. Write the procedure to insert the values in the customer transaction table trans.

Output:
SQL> create table bankmaster( accno number(15),accname varchar2(20),address varchar2(20),
balance number(10));
Table created.
SQL> desc bankmaster;
Name Null? Type

ACCNO NUMBER(15)
ACCNAME VARCHAR2(20)
ADDRESS VARCHAR2(20)
BALANCE NUMBER(10)

SQL> create table trans(accno number(15), accname varchar2(20),transdate date, transtype


varchar2(1), amt number(10));
Table created.
SQL> desc trans;
Name Null? Type

ACCNO NUMBER(15)
ACCNAME VARCHAR2(20)
TRANSDATE DATE
TRANSTYPE VARCHAR2(1)
AMT NUMBER(10)

SQL> set serveroutput on;

SQL> ed b1;
create or replace procedure custadd(x1 number, x2 varchar, x3 varchar, x4 number) as
acno number;
acname varchar2(20);
add varchar2(20);
bal number;
begin

DBMS Lab Manual 62


Acropolis Institute of Technology & Research, Indore
acno:= x1;
acname:=x2;
add:=x3;
bal:=x4;
insert into bankmaster values(acno,acname,add,bal);
dbms_output.put_line('Record Inserted');
end;
SQL> @ b1;
/
Procedure created.
SQL> exec custadd(8080,'Anish','Trichy',5000);
Record Inserted
PL/SQL procedure successfully completed.

SQL> exec custadd(8081,'Sham','Salem',10000);


Record Inserted
PL/SQL procedure successfully completed.

SQL> exec custadd(8082,'Yugesh','Erode',7000);


Record Inserted
PL/SQL procedure successfully completed.

SQL> select * from bankmaster;


ACCNO ACCNAME ADDRESS BALANCE

8080 Anish Trichy 5000


8081 Sham Salem 10000
8082 Yugesh Erode 7000

SQL> ed b2;
create or replace procedure custdelete( x number) as
acno number(10);
begin
acno:=x;
delete from bankmaster where accno = acno;
delete from bankmaster where accno = acno;
dbms_output.put_line('Record Deleted');
end;
SQL> @ b2;
/
Procedure created.
SQL> exec custdelete(8080);
Record Deleted

DBMS Lab Manual 63


Acropolis Institute of Technology & Research, Indore
SQL> select * from bankmaster;
ACCNO ACCNAME ADDRESS BALANCE

8081 Sham Salem 10000


8082 Yugesh Erode 7000

SQL> ed b3;
create or replace procedure custtrans( x1 number, x2 varchar2, x3 number) as
acno number(15);
actype varchar2(20);
bal number(10);
taccno number(15);
taccname varchar2(20);
tbalance number(10);
tdate date;
begin
acno:=x1;
actype:=x2;
bal:=x3;
select accno,accname,balance into taccno,taccname,tbalance from bankmaster
where accno = acno ;
if SQL%FOUND then
dbms_output.put_line('Record Found');
tdate:=sysdate;
if actype = 'D' then
insert into trans values(taccno,taccname,tdate,actype,bal);
update bankmaster set balance = tbalance + bal where accno=acno;
else
insert into trans values(taccno,taccname,tdate,actype,bal);
update bankmaster set balance = tbalance - bal where accno=acno;
end if;
else
dbms_output.put_line('No Record Not Found');
end if;
end;
SQL> @ b3;
/
Procedure created.

SQL> exec custtrans(8081,'D',2000);


Record Found
PL/SQL procedure successfully completed.

DBMS Lab Manual 64


Acropolis Institute of Technology & Research, Indore
SQL> select * from trans;
ACCNO ACCNAME TRANSDATE T AMT
-
8081 Sham 09-OCT-06 D 2000

SQL> exec custtrans(8082,'W',2000);


Record Found
PL/SQL procedure successfully completed.

SQL> select * from trans;


ACCNO ACCNAME TRANSDATE T AMT
-
8081 Sham 09-OCT-06 D 2000
8082 Yugesh 09-OCT-06 W 2000

SQL> select * from bankmaster;


ACCNO ACCNAME ADDRESS BALANCE

8081 Sham Salem 12000


8082 Yugesh Erode 5000

Result:
Thus the procedure for bank process was written and executed.

DBMS Lab Manual 65


Acropolis Institute of Technology & Research, Indore
PAYROLL PROCESSING
Aim:
To develop a package for Payroll processing.

Procedure:
1. Create the table for StaffMaster
2. Insert the values in the StaffMaster table.
3. Write the procedure to insert the values in the payment table after calculating the net salary
and gross salary.

Output:
SQL> Create Table StaffMaster( ID Number(3) , Name Varchar2(10) , Category Varchar2(1),
BasicSalary Number(8,2) , HRA Number(2), DA Number(2), EPF Number(5), LIC Number(5) );
Table created.

SQL> Desc StaffMaster;


Name Null? Type

ID NUMBER(3)
NAME VARCHAR2(10)
CATEGORY VARCHAR2(1)
BASICSALARY NUMBER(8,2)
HRA NUMBER(2)
DA NUMBER(2)
EPF NUMBER(5)
LIC NUMBER(5)

SQL> Insert Into StaffMaster Values( 101, 'Siva','T', 8000, 10, 15, 1000 , 500 );
1 row created.

SQL> Insert Into StaffMaster Values( 102, 'Kumar','N',10000, 10, 15, 800 , 600 );
1 row created.

SQL> Select * from StaffMaster;


ID NAME C BASICSALARY HRA DA EPF LIC
-
101 Siva T 8000 10 15 1000 500
102 Kumar N 10000 10 15 800 600

SQL> Create Table PayMent( ID Number(3), Name Varchar2(10), GrossSalary Number(10,2),


NetSalary Number(10,2) );
Table created.

DBMS Lab Manual 66


Acropolis Institute of Technology & Research, Indore
SQL> Desc PayMent;
Name Null? Type

ID NUMBER(3)
NAME VARCHAR2(10)
GROSSSALARY NUMBER(10,2)
NETSALARY NUMBER(10,2)
SQL> Select * from PayMent;
no rows selected
SQL> Create or Replace Procedure PayRoll( X Number) As
PName Varchar2(10);
PID Number(3);
PHRA Number(2) := 0;
PDA Number(2) := 0;
PEPF Number(5) := 0;
PLIC Number(5) := 0;
PBasicSalary Number(8,2) :=0;
PGrossSal Number(10,2) := 0;
PNetSal Number(10,2) := 0;
Begin
PID := X;
Select Name, BasicSalary, HRA, DA, EPF, LIC
Into PName, PBasicSalary, PHRA, PDA, PEPF, PLIC
from StaffMaster Where ID = PID;
PGrossSal := PBasicSalary + (PBasicSalary * (PHRA /100) ) +(PBasicSalary *(PDA / 100) );
PNetSal := PGrossSal - ( PEPF + PLIC );
Insert Into payment Values( PID, PName, PGrossSal, PNetSal );
End;
/
Procedure created.
SQL> Select * from PayMent;
no rows selected
SQL> EXEC PayRoll(101);
PL/SQL procedure successfully completed.
SQL> EXEC PayRoll(102);
PL/SQL procedure successfully completed.
SQL> Select * from PayMent;
ID NAME GROSSSALARY NETSALARY

101 Siva 10000 8500


102 Kumar 12500 11100
Result:
Thus the procedure for bank process was written and executed.

DBMS Lab Manual 67


Acropolis Institute of Technology & Research, Indore
EMBEDED SQL
Aim:
To write a java program for storing data in Oracle / MySql.

Procedure:
i) Create a table with necessary fields.
ii) Write a java program to display data from table.
iii) Compile and execute the java program.

OUTPUT:
SQL> desc EMP;
Name Null? Type

EMPNO NUMBER(5)
ENAME VARCHAR(25)
SAL NUMBER(7)
DEPTNO NUMBER(5)

Program:
/* Program for Jdbc Connectivity*/
import java.sql.*;
public class ESQLExample {
// JDBC driver name and database URL
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost/EMP";
// Database credentials
static final String USER = "username";
static final String PASS = "password";

public static void main(String[] args) {


Connection conn = null;
Statement stmt = null;
try{
// Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");
// Open a connection
System.out.println("Connecting to database...");
conn = DriverManager.getConnection(DB_URL,USER,PASS);
// Execute a query
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql;
sql = "SELECT EMPNO, ENAME, SAL, DEPTNO FROM EMP";

DBMS Lab Manual 68


Acropolis Institute of Technology & Research, Indore
ResultSet rs = stmt.executeQuery(sql);
// Extract data from result set
while(rs.next()){
//Retrieve by column name
int EMPNO = rs.getInt("EMPNO");
String ENAME = rs.getString("ENAME”);
int SAL = rs.getInt("SAL");
int DEPTNO = rs.getInt("DEPTNO");
//Display values
System.out.print("EMPNO: " + EMPNO);
System.out.print(", ENAME: " + ENAME);
System.out.print(", SALARY: " + SAL);
System.out.println(", DEPTNO: " + DEPTNO);
}
// Clean-up environment
rs.close();
stmt.close();
conn.close();
}catch(SQLException se){
// Handle errors for JDBC
se.printStackTrace();
}catch(Exception e){
//Handle errors for Class.forName
e.printStackTrace();
}finally{
//finally block used to close resources
try{
if(stmt!=null)
stmt.close();
}catch(SQLException se2){
}// nothing we can do
try{
if(conn!=null)
conn.close();
}catch(SQLException se){
se.printStackTrace();
}//end finally try
}//end try
System.out.println("Goodbye!");
}//end main
}//end ESQLExample
OUTPUT:
Thus a java program was written to retrieve store data and executed successfully.

DBMS Lab Manual 69


Acropolis Institute of Technology & Research, Indore
ER Diagram
AIM:
Preparing an ER diagram for given database and Conversion from ER diagram to tables

Database:
A Database is a collection of interrelated data and a Database Management System is a software
system that enables users to define, create and maintain the database and which provides
controlled access to the database.

ER- Diagram:
It is an Entity –Relationship diagram which is used to represent the relationship between different
entities. An entity is an object in the real world which is distinguishable from other objects. The
overall logical structure of a database can be expressed graphically by an ER diagram, which is
built up from following components.
Rectangles: represent entity sets.
Ellipses: represent attributes.
Diamonds: represent relationships among entity sets.
Lines: link attribute to entity sets and entity sets to relationships.

Mapping Cardinalities:
It expresses the number of entities to which another entity can be associated via a relationship
set. For a binary relationship set R between entity sets A and B.
The Mapping Cardinalities must be one of the following.
• One to one
• One to many
• Many to one
• Many to many

Conversion from ER diagram to tables

Step 1: Mapping of Regular Entity Types:


For each regular(strong) entity type E in the ER schema create a relation R that includes all the
simple attributes of E. Include only the simple component attributes of a composite ,the set of
simple attributes that form it will together form the primary key of R.

Step 2: Mapping of Weak Entity Types:


For each weak entity type W in the ER schema with owner entity type E, create a relation R and
include all the attributes of W and the specific attributes of R. In addition include the Primary key
attribute(s) of the owner entity type. The primary key of R is the combination of the primary
key(s) of the owner(s) and the partial key of the Weak Entity Type W.

DBMS Lab Manual 70


Acropolis Institute of Technology & Research, Indore
Step 3 : Mapping of Binary 1:1 Relationship Types :
For each binary 1:1 relationship type R in the ER schema, identify the relations S and T that
correspond to the Entity Types participating in R. Choose one of the relations- S, say – and include
as a Foreign key in S the primary key of T. It is better to choose an entity type with total
participation in R in the role of S. Include all the simple attributes (or simple components of a
composite attributes) of the 1:1 relationship type R as attributes of S.

Step 4: Mapping of Binary 1:N Relationship Types :


For each regular binary 1:N relationship type R, identifying the relation S that represent the
participating Entity Type at the N side of the relationship type. Include as Foreign key in S the
primary key of T that represents the other entity type participating in R; this is done because each
entity instance on the N side is related to at most one entity instance on the 1-side of the
relationship Type. Include any simple attributes (or simple components of composite attributes)
of the 1:N relationship type as attributes of S.

Step 5: Mapping of Binary M:N Relationship Types :


For each binary M:N relationship type R, create a new relation S to represent R. Include the
primary key of the participating entity types; their combination will form the primary key of S.
Also include any simple attributes of the M:N relationship types (or simple components of a
composite attributes) as attributes of S.

Step 6: Mapping of Multivalued Attributes:


For each Multivalued Attribute A, create a new relation R. This relation R will include an attribute
corresponding to A, plus the primary key attribute K- of the relation that represents the entity
type or relationship type that has A as an attribute. The primary key of R is the combination of A
and K. If the multivalued attribute is composite, we include its simple components.

Step 7: Mapping of N-ary Relationship Types:


For each N-ary relationship type R, where N>2, create a new relation S to represent R. Include the
primary keys of the relations that represent the participating entity types. Also include any simple
attributes of the N-ary relationship types (or simple components of a composite attributes) as
attributes of S.

Conclusion:
Referring to the problem statement the ER diagram was designed and converted into the tables.

Post Lab Questions:


1. Explain Types of attributes.
2. Explain Constraints on Generalization and Specialization.

Problem Statement:
An Organization has a database which maintains the records for the customer which places the
order(s) through the salesmen. There can be more than one customer who places the order(s)

DBMS Lab Manual 71


Acropolis Institute of Technology & Research, Indore
through a single salesman or there can be single customer which places the order(s) through
multiple salesmen. Create the database for this problem statement.

Procedure - Analyzing the Problem:


According to above problem statement, name the relation by identifying the noun and the
associating relation (Relationship set) by identifying the verb. Here, Customers and Salesmen are
noun so they are considered as Entity and Order is verb so it is considered as Relationship. After
assigning the name of the relation, identify the attributes for each of the relations. Also identify
the primary key for each of the relation. Then draw E-R diagram.

Designing the Solution: E-R diagram

Implementing the Solution Using Writing Source Code for Table:

CREATE TABLE CUSTOMERS:


CREATE TABLE CUSTOMERS (CID VARCHAR2(5) PRIMARY KEY, CNAME VARCHAR2(20), CITY
VARCHAR2(20), STATE VARCHAR2(15), PINCODE NUMBER(8), PRODUCT VARCHAR2(20), CLASS
CHAR(1) DEFAULT ‘A’);

CREATE TABLE SALESMEN:


CREATE TABLE SALESMEN (SID VARCHAR2(5) PRIMARY KEY, SNAME VARCHAR2(20), CITY
VARCHAR2(15), SALARY NUMBER(5,2), PRODUCT VARCHAR2(20), TGTTOGET NUMBER(5,2),
COMM NUMBER(5,2));

CREATE TABLE ORDER:


CREATE TABLE ORDER1(OID VARCHAR2(5) PRIMARY KEY, CID VARCHAR2(5), SID VARCHAR2(5),
PRODUCT VARCHAR2(20), QTY NUMBER(5), ODATE DATE , O_AMT NUMBER(8,2), FOREIGN
KEY(CID) REFERENCES CUSTOMERS, FOREIGN KEY(SID) REFERENCES SALESMEN, CHECK (O_AMT
>=0));

DBMS Lab Manual 72


Acropolis Institute of Technology & Research, Indore
Exercise on ER Diagram
Following are the requirements of the Company for building a ERP.

• The company is organized into DEPARTMENTs. Each department has a name, number and an
employee who manages the department. We keep track of the start date of the department
manager.
• Each department controls a number of PROJECTs. Each project has a name, number and is
located at a single location.
• We store each EMPLOYEE’s social security number, address, salary, sex, and birthdate. Each
employee works for one department but may work on several projects. We keep track of the
number of hours per week that an employee currently works on each project. We also keep
track of the direct supervisor of each employee.
• Each employee may have a number of DEPENDENTs. For each dependent, we keep track of
their name, sex, birthdate, and relationship to employee.
• More than one relationship type can exist with the same participating entity types. For
example, MANAGES and WORKS_FOR are distinct relationships between EMPLOYEE and
DEPARTMENT, but with different meanings and different relationship instances.

Design the ER diagram for this problem statement and convert into relational model.

DBMS Lab Manual 73


Acropolis Institute of Technology & Research, Indore
Mini Project
Mini project on designing and implementing one data base management system.

Contents of PROJECT REPORT

• Project Title
• Certificate
• Acknowledgement
• System Overview
◼ Current system
◼ Objectives of the proposed system
• Advantages of the Proposed system (over current)
• E.R. Diagram
◼ Entities
◼ Relationships
◼ Mapping Constraints
• Database Schema/Table Definition
◼ Table Name
◼ Field Name
◼ Data type
◼ Field size
◼ Constraint (e.g. auto generated, primary key, foreign key)
◼ Validation (e.g. not null, default value)
• Implementation using Java or .NET
• Output
• Future Enhancements of the system
• Bibliography

Note: From the 3rd lab reporting will be started for project.

DBMS Lab Manual 74


Acropolis Institute of Technology & Research, Indore
Frequently Asked Questions
• What is database?
• What is DBMS?
• What is a Database system?
• What are the Advantages and disadvantages of DBMS?
• What is a view? How it is related to data independence?
• What is E-R model?
• What is an Entity?
• What is an Entity set?
• What is DDL (Data Definition Language)?
• What is DML (Data Manipulation Language)?
• What is a query?
• What do you mean by Correlated subquery?
• What are the unary operations in Relational Algebra?
• Are the resulting relations of PRODUCT and JOIN operation the same?
• Define SQL and state the differences between SQL and other conventional programming
Languages
• What is database Trigger?
• What are cursors give different types of cursors?
• What operator performs pattern matching?
• What operator tests column for the absence of data?
• Which command executes the contents of a specified file?
• What are the wildcards used for pattern matching?
• What are the privileges that can be granted on a table by a user to others?
• What command is used to get back the privileges offered by the GRANT command?
• Which system table contains information on constraints on all the tables created?
• What the difference is between TRUNCATE and DELETE commands?
• What will be the output of the following query?
SELECT DECODE (TRANSLATE ('A', '1234567890','1111111111'), '1', 'YES', 'NO');
• What does the following query do? SELECT SAL + NVL(COMM,0) FROM EMP;
• Which date function is used to find the difference between two dates?
• Which function is used to find the largest integer less than or equal to a specific value?
• What is the use of CASCADE CONSTRAINTS?
• What is the use of DESC in SQL?

DBMS Lab Manual 75


Quality is never an accident;
It is always the result of
high intention,
sincere effort,
intelligent direction and
skillful execution.

DBMS Lab Manual 76


C. Assessment Tools and Attainment
1. Assessment Tools and Weightage to Attain CO
Students will be evaluated using selected assessment measures throughout the semester (Tick methods
used):

1. RGPV Theory Exams


2. Class and/or Lab Assignments
3. Mid Semester Exam
4. Lab/Project Work
5. Tutorial
6. Quiz(Theory and Practical)
7. Viva-voce
8. Attendance and Class Performance
9. Paper Publication
10. Case Study/Presentations
11. Mini Project
12. Add-On Courses/ Certification
13. Programming Challenges
2. Assignment and Tutorial Sheet
Date of Assignment: 01 August 2021
Due date: 30 September 2021.
UNIT 1:

1. Discuss the main characteristics of the database approach. What are the various components of
database system? Explain DBMS architecture. How DBMS differs from traditional file management
system?
2. What do you understand by different level of data abstraction? Describe the three-schema architecture.
Also explain objectives of three levels architecture. Why do we need mapping between schema levels?
How do different schema definition languages support this architecture? What is the difference
between logical data independence and physical data independence? Which one is harder to achieve
and why?
3. What is DBMS? Also explain the advantages of DBMS. List and describe the different types of databases.
What are the different types of database users? What are the main functions and responsibilities of
database administrator? Explain the responsibilities of DBA?
4. What is NULL? Give an example to illustrate testing for NULL in SQL. What is dangling tuple problem?
5. What is Data model? Discuss the main category of Data models. Define the various Data models and list
their advantages and disadvantages. Explain the distinction between representation of association,
relationship, and basic operation in Data models.
6. Compare and contrast the features of hierarchical, network and relational data models with their
advantages and disadvantages. What business needs led to the development of each of them? Compare
the procedure of insert, Delete and Update operations in network and relational model.
7. Explain the concept of Intension and Extensions. Differentiate between Intension and Extension. Explain
and contrast schema, sub-schema, and instance.
8. What are views? How views and foreign keys are useful in RDBMS? Explain with example. What are the
major problems with processing update operations expressed in terms of views? What is the
significance of using the views? Write a command to create the view.
9. Explain the concept of Generalization, Aggregation and Specialization with proper example. What are
the benefits to use these concepts to design database?
10. Transform following ER diagram into a well-structured relation with proper explanation / steps.
UNIT 2:

11. Explain Domain, Tuple, Attributes, Degree, and Cardinality of relation.


12. Write down major steps that you would take in setting up a database for enterprise. Also give procedure
to convert an E-R diagram into relation model. How weak entity can be converted to a strong entity.
Outline what sort of redundancy will result by converting weak entity to strong entity.
13. Define the following with respect to an E-R diagram and explain with example

a) Attribute - simple, derived, composite, multi-valued

b) Entity - strong, weak

c) Relationship – instance, type, set

d) Cardinality - One to One, One to Many, Many to Many


e) Participation - Full, Partial

f) Degree of relation

g) Aggregation

h) Physical schema

i) Specialization and generalization


14.A university database contains information about professors (identified by social security number)
and courses (identified by courseid) professors teach courses, each of the following situations
concerns the teaches relationship set. For each situation draw an E-R diagram
a) Professors can teach the same course in several semesters and each offering must be
recorded.

b) Professors can teach the same course in several semesters and only the most recent such
offering needs to be recorded.

c) Every professor must teach some course.

d) Every professor teaches exactly one course.

e) Every professor teaches exactly one course, and every course must be taught by some
professor.

15.Describe the basic features of the relational data model in detail. Discuss their advantages and
disadvantages and importance to the end user and the designer. Also explain the Data Control
facilities in Relational Model. What are the major aspects in which the relational model deals?
16. Define and differentiate primary key, candidate key, foreign key, composite key and alternate
key and super key with the help of example. Why do we designate one of the candidate keys of a
relation to be the primary key?
17. What are Integrity Rules? Discuss the entity integrity and referential integrity constraints. Explain
with example why each is considered important? Explain the significance of primary key and
foreign key in employee database. Discuss with example, the types of integrity constraints that
must be checked for the Update, Insert and Delete operations.
18. What is Join? Explain natural, theta, inner, left outer, right outer and full outer join with
examples. Discuss the various types of inner join operations. Why does theta join required?
Differentiate between Natural join and Theta join.
19. Explain about set operations in relational algebra. What are the conditions to be fulfilled for two
relations to be involved in a Union operation? Why do the Union, Intersection and Set Difference
operation require the operand relations to be Union compatible?
20. Discuss the selection, projection and join operator of relation algebra with a suitable example.
What are the relational algebraic operations (other than set operations) developed specifically
for a relational database? Explain the use of division relational operator with example. What are
the relational algebra operations supported in SQL and write equivalent SQL statements for each
operation?
21. Explain the following terms to show your understanding of their essential features: (a) relational
algebra (b) relational calculus (c) tuple calculus (d) domain calculus (e) QUEL
22.Draw the ER Diagram for following
a) Hospital
b) University
c) Bank
d) Loan
UNIT 3:

23. Given the relation schema -


S_emp (ld, Last_name, First_name, Userid, Start-date, Designation, Dept_id, Salary). Give
queries expressed in SQL -

a) Display the last name, first name and department Id for all employees who do not work in
department 44.
b) Display the last name, user id and start date for all employees hired on March 8, 1990.
c) Display the last name, first name and salary of all employees whose salary is less than S
l,200.
d) Display the last name, first name and salary of all the employees who are managers. Order
the result in ascending order by salary.
e) Increase the salary of all employees of department 41 by 1000.
24.Employee (SSN, name, age, dno) Salary (Qi, salary) Works on (Projects#, SSN), Project (Projects#,
project_name, location) . For each of the following queries give an expression in SQL
a) Display the names of projects at “delhi”.
b) Find the project name of employee whose salary is greater than 10000.
c) Retrieve the name and SSN of employees working on Project#A 100.

25. Solve the following on the given database. Write the SQL and Relational Algebra
for given Queries:
S (S. No, Sname, City , States), P (Pno, Pname, Color, Weight), SP (Sno, Pno, QTY)

a) Get Supplier name who supply at least one red part

b) Get Supplier number who supplies maximum quantity.

c) Get Supplier number who supply quantity greater than average quantity

d) Increase the quantity of part P1 by 10%

e) Change the color of Red parts supplied by Ajay to Green.

26. Consider the relational database given below:


Lives(person_name, street, city), Works(person_name, company_name, salary), Locatedin
(company_name, city), Manager(person_name, manager_name)

Give an expression in SQL for each of the queries below-

a) Find the company with the smallest payroll.

b) Find the company with the most employees.

c) Give all managers a10% raise.

27. Consider the following relational schema Employee (empno, name, office, age)
Books (isbn, title, authors, publisher) Loan (empno, isbn, date)

Write the following queries in relational algebra.

a) Find the names of employees who have borrowed a book Published by McGraw Hill.

b) Find the names of employees who have borrowed all books Published by McGraw-Hill.

c) Find the names of employees who have borrowed more than five different books
published by McGraw-Hill.
d) For each publisher, find the names of employees who have borrowed More than five
books of that publisher.

28. Consider the following relations with keys underlined Street(name, location, city)
House(number, street_name)
Lives(name, house_number)

For the above relations answer the following queries in SQL.

a) Get the house numbers street wise.

b) Get the numbers of houses which are not occupied.

29.Consider the relational database given below. Give expressions in QBE and for each of the following
queries.

Employee (Person-name, street, city), Works (Person-name, company-name, salary) Company


(Company-name, city), Manager (person-name, Manager-name)

a) Give all managers in the database a 10% raise.


b) Find name of all employees who work in xyz.
c) Find all employees who do not work in xyz.
d) Modify the database so that the 'Jones' now lives in Newtown.

UNIT 4:

30. Explain what is meant by repetition of information and inability to represent information.
Explain why each of these properties may indicate a bad relational database design. List the three
design goals for relational database and explain why each is desirable.
31. What is normalization? Discuss the purpose of normalization in DBMS. What is functional
dependency? Explain the role of FD in the process of normalization. Explain 1NF, 2NF, 3NF and
BCNF with simple example. Explain the similarity and dissimilarities between BCNF and 3rd Normal
Form.
32. Prove that a relation which is in 4NF must be in BCNF. Give an example of a relation schema R
and a set of dependencies such that R is in BCNF but is not in 4NF.
33. Explain the cases where 4th normal form is applicable. What is multi-valued dependency?
What type of constraints does it specify? When does it arise? What are the anomalies occurred due
multi-valued dependence and how these anomalies are rectified? What is meant by projection join
dependency and how it is handled by 5NF?
34. What is overlapping of candidate keys? What are the problems incurred due to this overlap
and how these problems are rectified? Give a set of functional dependencies for the relation
schema R (A, B, C, D, E) with primary key AB under which R is in 2NF but not in 3NF.

35. Explain Trivial and non-Trivial dependencies. What is partial dependency? With which normal
form is associated. What are inference rules for functional dependencies?
36. Consider the following relation: R (A, B, C, D, E).
The primary key of the relation is AB. The following functional dependencies hold: A-->C B--
>D AB -> E. Is the above relation in second normal form?

37. What do you mean by decomposition of a relation? Consider the relational scheme R (A, B, C,
D, E, F) and FDs A A’-»BC, C->A, D->E, F->A, E->D. Is the decomposition of R into R1(A, C, D), R2(B, C,
D) and R3(E, F, D) lossless? Explain the requirements for lossless decomposition and dependency
preserving.
38. Define the following terms - -
a) Functional dependency
b) Lossless decomposition
c) Dependency preservation
d) BCNF
39. Give closure of the following set F of functional dependencies for the relation R = (A, B, C, D, E)
where F = { A—>BC B—>D CD—>E E —> A}. Also list all candidate keys of R.
40.What is Query Optimization? What is the need of optimization? Explain the query optimization
concept with help of example. What will be the benefits of query optimizations?
41.Explain various algorithms to implement select, project, and join operations of relational algebra
with proper example.
42.Explain the types of optimization methods with the help of example. Compare heuristic based &
cost estimation-based methods with example.

UNIT 5:

43.What is meant by checkpoint? What is its importance? What are the steps performed during
checkpoint? Explain the recovery process after system failure using checkpoint.
44.What is meant by forward and backward recovery techniques? Explain various recovery
techniques during transaction in detail.
45.Explain four important properties of transaction that a DBMS must ensure to maintain database.
Database system implementers have paid much more attention to the ACID properties that have
file system implementers. Why might this be the case?
46.State and explain the features of object-oriented data model. What are the advantages and
disadvantages of object-oriented database? How does an object in object-oriented model differ
from the concept of an entity in entity relationship model?
47.What are concurrent operations and concurrency control? How is it implemented in DBMS?
48.What DBMS component is responsible for concurrency control? How is this feature used to
resolve conflicts? Describe the three most common concurrent transaction execution problems.
How concurrency control can be used to avoid those problems. Explain Lock based protocol and
Time stamp-based protocol for concurrency control.
49.What are the advantages of the tree locking protocol over the two-phase locking protocol?
Explain the phantom phenomena. Why may these phenomena lead to an incorrect concurrency
execution despite use of a protocol that ensures serializability? Explain distinction between term
serial schedule and serializable schedule.
50.What is meant by distributed DBMS and discuss the need of Distributed DBMS? Explain relative
advantages of centralized and distributed databases. List and discuss some of the factors that
influenced the evaluation of the DDBMS. Illustrate the issues to implement distributed
databases.
51.Explain the transparency features of a DDBMS. Explain how fragmentation transparency,
replication transparency and location transparency differ. Compare different strategies of data
allocation and explain mixed fragmentation with examples.
52.Discuss the factor that does not appear in centralized systems that affect concurrency control
and recovery in distributed system. Discuss various locking protocols in distributed database.
53.What is OODBMS? Explain the working of any one OODBMS system. Compare the OODBMS and
DBMS with proper example.
54.Explain the concepts and need of Temporal, Deductive, Multimedia, Web & Mobile database.
55.Explain the architecture of MySQL. Explain the steps to provide roles to users in MySQL. What
are the steps to extract data from multiple tables in MySQL?
56.What are Hierarchical quires, inline queries, and flashback queries. Explain with proper example.
What is the need of such type of queries?
57.Explain anonymous block, nested anonymous block, branching and looping in ANSI SQL with
proper example.
58.What is Cursor management. Explain nested and parameterized cursors. Explain Stored
procedures, in, out, in out type parameters, usage of parameters in procedures.
59.How to create User defined functions? Explain user defined functions limitations. Explain
Triggers with proper example.
60.What is NoSQL? Explain types of NoSQL DBMS. Compare NoSQL and SQL database management
systems.

3. Quiz/Unit Test/ Class Test


3. Quiz/Unit Test/ Class Test
5/23/22, 2:11 AM DBMS Unit 1

NAME : 

CLASS : 
DBMS Unit 1
DATE  : 
25 Questions

1. The conceptual schema defines the view or views for particular users.

A True B False

2. Which of the following is an example of a DBMS

A PHP B Microsoft Office

C Oracle D SQL

3. A data-manipulation language (DML) is a language that enables users to access

A Retrieval of information stored in the database B Insertion of new information into the database

Deletion of information from the database specify the database


C D
schema

E Modification of information stored in the database

4. The overall design of the database is called the database

A schema B instance

C logical structure D physical structure

5. There are -------------levels of abstraction

A 3 B 2

C 4 D 1

6. __________ of abstraction explains how data is actually stored and describes the Data Structure and Access methods used
by database.

A None of the above B View level

C Physical level D Logical level

7. Which one is not a user type in DBMS.

A DBA B End User

C Application Programmers D Tester

https://quizizz.com/print/quiz/6135ab1d54e8a4001d7c6441 1/3
5/23/22, 2:11 AM DBMS Unit 1

8. What is the Functionality of Query Optimizer?

A None of the Above B Produces Efficient Execution Plan

C Maintains Information about locks D Executes the Query

9. Data independence is the type of data transparency that matters for a centralized DBMS

A False B True

10. Select from the following the advantages of DBMS:

A Data Integrity B Complexity

C Data Consistency D Increased Application development time

11. In _______________________ model the data is represented as relations

A Unifying model B Network model

C Relational model D Heirarchial model

12. The set of relations and set of domains that defines the way data can be represented as ______________________

A data structure B none of the above

C data manipulation D data integrity

13. Relational Database Management System consists of:

A A Schema B A set of tables

C both schema and set of tables

14. ___________ is a description of data in terms of data model

A schema B table

C relation D tuple

15. ................... is a collection of processes that facilitate the designing, development, implementation and maintenance of
enterprise data management systems.

A Database B Database design

C Algorithm D DBMS

16. ER model stands for an ............

A Hierarchical model B Entity-Relationship model

C Relational model D Network model

17. In the ER diagram, an entity can be represented as ...........

A Triangles B Square

C Rectangles D Diamond

https://quizizz.com/print/quiz/6135ab1d54e8a4001d7c6441 2/3
5/23/22, 2:11 AM DBMS Unit 1

18. An entity that depends on another entity called a .........

A Strong entity B Relationship

C Key D Weak entity

19. .......... is used to represent an attribute.

A Diamond B Circle

C Eclipse D Rectangle

20. An attribute that composed of many other attributes is known as a ...........

A Multi-valued attribute B Attribute

C Cell D Composite attribute

21. An attribute can have more than one value are known as a .........

A Attribute B Composite attribute

C Entity D Multivalued attribute

22. An attribute that can be derived from other attribute is known as a .........

A Composite attribute B Attribute

C Derived attribute D Multi-valued attribute

23. ......... is used to represent the relationship.

A Eclipse B Rectangle

C Line D Diamond

24. A .......... in DBMS is the most popular client server architecture in DBMS in which the development and maintenance of
functional processes, logic, data access, data storage, and user interface is done independently as separate modules.

A 1 Tier architecture B n Tier architecture

C 3 Tier architecture D 2 Tier architecture

25. Which one of the following refers to the total view of the database content?

A Physical view B Conceptual view

C Internal view D External view

https://quizizz.com/print/quiz/6135ab1d54e8a4001d7c6441 3/3
5/23/22, 2:14 AM Unit 2 Quiz DBMS July Dec 2021 5/23/22, 2:14 AM Unit 2 Quiz DBMS July Dec 2021

5. The operators in SELECT operation statement such as and , or and not are * 1 point

Unit 2 Quiz DBMS July  Dec 2021 classified as

Mark only one oval.


The respondent's email (null) was recorded on submission of this form.
* Required Boolean operators

Tuple operators
1. Email * String operators

Insertion operators

2. Enrollment Number * 6. If in the JOIN operation, the conditions of JOIN operation are not * 1 point

satisfied then the results of the operation is

Mark only one oval.

zero tuples and empty relation


3. Name *
one tuple from one relation

zero tuples from two relation

two tuples from empty relations

4. In unary relational operations, the SELECT operation is partition of relation * 1 point


usually classified as

Mark only one oval. 7. The DIVISION operation can be applied to two relations A and B such as * 1 point

R(A) ÷ R(B) where as


Horizontal partition
Mark only one oval.
Vertical partition

Insert partition A does not belong to B

Delete partition A must be added to B

A belongs or equal to B

A must be subtracted from B

https://docs.google.com/forms/d/1wLEVFUwd7eN3-vNLMdSjLzLAYhAkulRAyLERoTzA_Uc/edit 1/11 https://docs.google.com/forms/d/1wLEVFUwd7eN3-vNLMdSjLzLAYhAkulRAyLERoTzA_Uc/edit 2/11


5/23/22, 2:14 AM Unit 2 Quiz DBMS July Dec 2021 5/23/22, 2:14 AM Unit 2 Quiz DBMS July Dec 2021

8. In the EQUIJOIN condition, the operation which is used to avoid * 1 point 11. The operation which allows to process relationships from multiple * 1 point

superfluous attribute is classified as relations rather than single relation is classified as

Mark only one oval. Mark only one oval.

ALPHA JOIN division operation

NATURAL JOIN relation operation

UNNATURAL JOIN square operation

THETA JOIN join operation

9. The Boolean expression used in the SELECT operation consists of clauses * 1 point 12. The operation which is used to take union of tuples from the relations * 1 point

such as that are not union compatible is classified as

Mark only one oval. Mark only one oval.

attribute name FULL UNION operation

constant value JOIN UNION operation

comparison operators OUTER UNION operation

All INNER UNION operation

10. The types of binary operations includes * 1 point 13. If matching tuples are not found, the kind of OUTER JOIN operation * 1 point

which keeps all the tuples of first and second relation is classified as
Mark only one oval.
Mark only one oval.
union
LEFT OUTER JOIN
intersection
FULL OUTER JOIN
set difference
HALF OUTER JOIN
all of the mentioned
DOWNWARD JOIN

https://docs.google.com/forms/d/1wLEVFUwd7eN3-vNLMdSjLzLAYhAkulRAyLERoTzA_Uc/edit 3/11 https://docs.google.com/forms/d/1wLEVFUwd7eN3-vNLMdSjLzLAYhAkulRAyLERoTzA_Uc/edit 4/11


5/23/22, 2:14 AM Unit 2 Quiz DBMS July Dec 2021 5/23/22, 2:14 AM Unit 2 Quiz DBMS July Dec 2021

14. The operations which are used to enhance the power of expression of * 1 point 17. The kind of operation by which one tuple can be created with the help of * 1 point
relational algebra includes combining tuples from two relations is classified as

Mark only one oval. Mark only one oval.

generalized projection square operation

recursive closure operations join operation

outer JOIN operations division operation

all of the mentioned relation operation

15. In unary relational operations, the symbols such as equal to, less than * 1 point 18. Consider two tuples X and Y, the operation whose result includes tuples * 1 point
and greater than are classified as that are only in X but not in Y is classified as

Mark only one oval. Mark only one oval.

tuple operators square of relation X and Y

column operators union of relation X and Y

comparison operators intersection of relation X and Y

row operators difference of relation X and Y

16. The JOIN operation which uses any of the comparison operators is * 1 point 19. As compared to Cartesian product, the tuples which appears in the * 1 point
classified as result by applying JOIN are the ones

Mark only one oval. Mark only one oval.

THETA JOIN that fulfills the condition

CHI-JOIN that does not fulfill the condition

PI-JOIN that are nested

SIGMA-JOIN that are subtracted

https://docs.google.com/forms/d/1wLEVFUwd7eN3-vNLMdSjLzLAYhAkulRAyLERoTzA_Uc/edit 5/11 https://docs.google.com/forms/d/1wLEVFUwd7eN3-vNLMdSjLzLAYhAkulRAyLERoTzA_Uc/edit 6/11


5/23/22, 2:14 AM Unit 2 Quiz DBMS July Dec 2021 5/23/22, 2:14 AM Unit 2 Quiz DBMS July Dec 2021

20. The expression used in relational calculus to specify request of retrieval * 1 point 23. The degree of the PROJECT operation is equal to * 1 point

is classified as
Mark only one oval.
Mark only one oval.
number of entities
declarative expression
number of attributes
procedural expression
number of columns
structural expression
number of rows
functional expression

24. The operations used to combine multiple relations to present * 1 point


21. The compatibility condition which states that the relations for union and * 1 point information in single table are classified as
intersection operations must consist of same type of tuples is classified
Mark only one oval.
as

Mark only one oval. outer relations

inner joins
union compatibility
outer joins
intersect compatibility
inner relations
row compatibility

column compatibility

25. The JOIN operation in which only equality operator is used is classified * 1 point
as
22. If the common attributes of two relations are classified as join attributes * 1 point
Mark only one oval.
then the OUTER UNION must be equal to

Mark only one oval. CHI-JOIN

PI-JOIN
LEFT OUTER JOIN
SIGMA-JOIN
FULL OUTER JOIN
EQUI JOIN
HALF OUTER JOIN

DOWNWARD JOIN

https://docs.google.com/forms/d/1wLEVFUwd7eN3-vNLMdSjLzLAYhAkulRAyLERoTzA_Uc/edit 7/11 https://docs.google.com/forms/d/1wLEVFUwd7eN3-vNLMdSjLzLAYhAkulRAyLERoTzA_Uc/edit 8/11


5/23/22, 2:14 AM Unit 2 Quiz DBMS July Dec 2021 5/23/22, 2:14 AM Unit 2 Quiz DBMS July Dec 2021

26. In unary relational operations, the PROJECT operation is partition of * 1 point 29. The operation which is used to select the subset of tuples by satisfying * 1 point

relation usually classified as the selection constraint and the selection is made from relation is
classified as
Mark only one oval.
Mark only one oval.
horizontal partition

vertical partition CHOOSE operation

insert partition SELECT operation

delete partition NON-SELECT operation

SUBSET operation

27. The JOIN operation in which two attributes joined have same name in * 1 point
both relations is classified as 30. If matching tuples are not found, the kind of OUTER JOIN operation * 1 point

Mark only one oval. which keeps all the tuples of second relation out of the two relations is
classified as
UNNATURAL JOIN
Mark only one oval.
THETA JOIN

ALPHA JOIN UPWARD JOIN

NATURAL JOIN DOWNWARD JOIN

LEFT OUTER JOIN

RIGHT OUTER JOIN

28. Consider two tuples A and B, the operation whose result includes tuples * 1 point

that are included in both relations is classified as

Mark only one oval. 31. If matching tuples are not found, the kind of OUTER JOIN operation * 1 point
which keeps all the tuples of first relation out of the two relations is
intersection of relation A and B classified as
difference of relation A and B
Mark only one oval.
square of relation A and B
LEFT OUTER JOIN
union of relation A and B
RIGHT OUTER JOIN

UPWARD JOIN

DOWNWARD JOIN

https://docs.google.com/forms/d/1wLEVFUwd7eN3-vNLMdSjLzLAYhAkulRAyLERoTzA_Uc/edit 9/11 https://docs.google.com/forms/d/1wLEVFUwd7eN3-vNLMdSjLzLAYhAkulRAyLERoTzA_Uc/edit 10/11


5/23/22, 2:14 AM Unit 2 Quiz DBMS July Dec 2021

32. The operation which only selects some of the columns from table and * 1 point
neglect the remaining columns is classified as

Mark only one oval.

OR operation

AND operation

TABLE operation

PROJECT operation

33. The process in which tuple is created by having combined attributes * 1 point
from two relations is classified as

Mark only one oval.

Cartesian compatibility

Cartesian multiples

Cartesian product

Cartesian ordinate

This content is neither created nor endorsed by Google.

 Forms

https://docs.google.com/forms/d/1wLEVFUwd7eN3-vNLMdSjLzLAYhAkulRAyLERoTzA_Uc/edit 11/11
5/23/22, 2:15 AM Unit 3 Quiz 5/23/22, 2:15 AM Unit 3 Quiz

5. In standard query language, the rows and columns are called respectively * 1 point

Unit 3 Quiz Mark only one oval.

The respondent's email (null) was recorded on submission of this form. tuple and attributes
* Required
quantifiers and identifiers

predicator and indicator


1. Email *
non-identifiers and quantifier

6. The clause used in SQL for ensuring referential integrity is classified as * 1 point
2. Name *
Mark only one oval.

PRIMARY KEY clause

SECONDARY KEY clause


3. Enrollment Number * FOREIGN KEY clause

INTERVAL KEY clause

Quiz Questions
7. The command used in SQL which deletes the table definition as well as all * 1 point

the records available in the table is called


4. If every functional dependency in set E is also in the closure of F then this * 1 point
is classified as Mark only one oval.

Mark only one oval. DELETE command

DROP TABLE command


FD is covered by E
PRIMARY KEY command
E is covered by F
SECONDARY KEY command
F is covered by E

F+ is covered by

https://docs.google.com/forms/d/1f_LNtwYNT1rPnlqPWyvru90ORCdKrO9YLmvTvF1B9tc/edit 1/8 https://docs.google.com/forms/d/1f_LNtwYNT1rPnlqPWyvru90ORCdKrO9YLmvTvF1B9tc/edit 2/8


5/23/22, 2:15 AM Unit 3 Quiz 5/23/22, 2:15 AM Unit 3 Quiz

8. Select ________ dept_name from instructor;  Here which of the following * 1 point 11. If there is more than one key for relation schema in DBMS then each key * 1 point

displays the unique values of the column ? in relation schema is classified as

Mark only one oval. Mark only one oval.

All prime key

From super key

Distinct candidate key

Name primary key

9. Aggregate functions are functions that take a ___________ as input and * 1 point
12. The property of normalization of relations which guarantees that * 1 point
return a single value. functional dependencies are represented in separate relations after
Mark only one oval. decomposition is classified as

Mark only one oval.


Collection of values

Single value non-additive join property

Aggregate value independency reservation property

Both Collection of values & Single value dependency preservation property

additive join property

10. The ____ connective tests for set membership, where the set is a * 1 point

collection of values produced by a select clause. The ____ connective 13. The rule which states that addition of same attributes to the right side * 1 point
tests for the absence of set membership. and left side will results in other valid dependency is classified as
Mark only one oval. Mark only one oval.

Or, in referential rule


Not in, in inferential rule
In, not in augmentation rule
In, or reflexive rule

https://docs.google.com/forms/d/1f_LNtwYNT1rPnlqPWyvru90ORCdKrO9YLmvTvF1B9tc/edit 3/8 https://docs.google.com/forms/d/1f_LNtwYNT1rPnlqPWyvru90ORCdKrO9YLmvTvF1B9tc/edit 4/8


5/23/22, 2:15 AM Unit 3 Quiz 5/23/22, 2:15 AM Unit 3 Quiz

14. The process of analyzing relation schemas to achieve minimal * 1 point 17. In the reflexive rule (IR1), the true dependencies generated are classified * 1 point
redundancy and insertion or update anomalies is classified as as

Mark only one oval. Mark only one oval.

normalization of data trivial

denomination of data nontrivial

isolation of data inferential

de-normalization of data functional

15. Considering the relational database, the functional dependency * 1 point 18. In normalization of relations, the property which is critical and must be * 1 point
between two attributes A and B is denoted by achieved is classified as

Mark only one oval. Mark only one oval.

A→B nonadditive join property

B←A additive join property

AB → R independency reservation property

R ← AB dependency preservation property

16. The procedure of storing higher normal form relations which are in lower * 1 point 19. The normalization form which is based on the transitive dependency is * 1 point
normal form as a base relation is classified as classified as

Mark only one oval. Mark only one oval.

isolation of data first normal form

de-normalization of data second normal form

normalization of data fourth normal form

denomination of data third normal form

https://docs.google.com/forms/d/1f_LNtwYNT1rPnlqPWyvru90ORCdKrO9YLmvTvF1B9tc/edit 5/8 https://docs.google.com/forms/d/1f_LNtwYNT1rPnlqPWyvru90ORCdKrO9YLmvTvF1B9tc/edit 6/8


5/23/22, 2:15 AM Unit 3 Quiz 5/23/22, 2:15 AM Unit 3 Quiz

20. The normal form which only includes indivisible values or single atomic * 1 point 23. Given FD's are AB -> C, C -> DE, E ->F and F -> A, find highest Normal * 1 point

values is classified as Form

Mark only one oval. Mark only one oval.

third normal form 1NF

first normal form 2NF

second normal form 3NF

fourth normal form BCNF

21. The concept in normalization of relations which is based on the full * 1 point 24. Find the normal forms in following Schemas : Registration (rollno, * 1 point

functional dependency is classified as courses) and FD {rollno -> courses} and rollno is a key attribute

Mark only one oval. Mark only one oval.

fourth normal form 1NF

third normal form 2NF

first normal form 3NF

second normal form BCNF

22. The rule that always generate true dependencies is called * 1 point

Mark only one oval. This content is neither created nor endorsed by Google.

referential rule
 Forms
inferential rule

closure rule

reflexive rule

https://docs.google.com/forms/d/1f_LNtwYNT1rPnlqPWyvru90ORCdKrO9YLmvTvF1B9tc/edit 7/8 https://docs.google.com/forms/d/1f_LNtwYNT1rPnlqPWyvru90ORCdKrO9YLmvTvF1B9tc/edit 8/8


5/23/22, 2:16 AM Unit 4 Quiz 5/23/22, 2:16 AM Unit 4 Quiz

4. ......... protocol is used to perform multiple transactions that execute on different *


Unit 4 Quiz database.

Mark only one oval.


The respondent's email (null) was recorded on submission of this form.
* Required Commit

Two phase lock


1. Email * Two phase commit

Locking

2. ........ means that a transaction must make its changes permanent to the * 5. When the transaction finishes the final statement the transaction enters into *
database ends.
Mark only one oval.
Mark only one oval.
Active state
Isolation Committed state
Locking Partially committed state
Durability Abort state
Consistency

6. Which of the following is an atomic sequence of database actions? *


3. Throughput means *
Mark only one oval.
Mark only one oval.
Transaction
Number of transactions that is committed in one hour Concurrency
Number of operations in a transaction Relations
Number of transaction that can be aborted in a given amount of time All of the mentioned
Number of transaction that can be executed in a given amount of time

7. Will undo all statements up to commit? *

Mark only one oval.

Transaction

Flashback

Rollback

Abort

https://docs.google.com/forms/d/1uO4tOd1yUrfbeFPeFvKj0Z7-ybKl6EgxhVXxz8k5x40/edit 1/5 https://docs.google.com/forms/d/1uO4tOd1yUrfbeFPeFvKj0Z7-ybKl6EgxhVXxz8k5x40/edit 2/5


5/23/22, 2:16 AM Unit 4 Quiz 5/23/22, 2:16 AM Unit 4 Quiz

8. State true or false: Using checkpoints reduces overhead * 12. In .........., one or more users/programs attempt to access the same data at the *
same time.
Mark only one oval.

True Mark only one oval.


False
Concurrency

Transaction control

Locking
9. In dirty read problem....... *
Two phase locking
Mark only one oval.

One transaction reads an uncommitted value of another transaction

One transaction reads the committed value for another transaction 13. Isolation of the transactions is ensured by *
One transaction reads another transaction Mark only one oval.
One transaction commits another transaction.
Transaction management

Application programmer

Concurrency control
10. A transaction can do only read operation and not write operation on a data *
Recovery management
item when it acquires ....... lock.

Mark only one oval.

Read mode 14. I and J are _________ if they are operations by different transactions on the *
Exclusive mode same data item, and at least one of them is a write operation.
Shared mode Mark only one oval.
Write mode
Conflicting

Overwriting

Isolated
11. If a transaction T has obtained an exclusive lock on item Q, then T can *
Durable
Mark only one oval.

read Q

write Q

both read and write Q

write Q but not read Q

https://docs.google.com/forms/d/1uO4tOd1yUrfbeFPeFvKj0Z7-ybKl6EgxhVXxz8k5x40/edit 3/5 https://docs.google.com/forms/d/1uO4tOd1yUrfbeFPeFvKj0Z7-ybKl6EgxhVXxz8k5x40/edit 4/5


5/23/22, 2:16 AM Unit 4 Quiz

15. Consider the following transactions with data items P and Q initialized to zero: *
      T1: read (P); read (Q) ;          if P = 0 then Q : = Q + 1 ;      write (Q) ;        T2:
read (Q) ;  read (P) ;      if Q = 0 then P : = P + 1 ;    write (P) ;

Mark only one oval.

A serializable schedule

A schedule that is not conflict serializable

A conflict serializable schedule

A schedule for which a precedence graph cannot be drawn

16.  Consider the following schedules involving two transactions. Which one of *
the following statement is true?     S1: R1(X) R1(Y) R2(X) R2(Y) W2(Y) W1(X)            
S2: R1(X) R2(X) R2(Y) W2(Y) R1(Y) W1(X)

Mark only one oval.

Both S1 and S2 are conflict serializable

Only S1 is conflict serializable

Only S2 is conflict serializable

None

This content is neither created nor endorsed by Google.

 Forms

https://docs.google.com/forms/d/1uO4tOd1yUrfbeFPeFvKj0Z7-ybKl6EgxhVXxz8k5x40/edit 5/5
5/23/22, 2:22 AM Unit 5 Quiz 5/23/22, 2:22 AM Unit 5 Quiz

4. In a PL/SQL block, a variable is declared as NUMBER without an initial value. *


Unit 5 Quiz What will its value be when it is first used in the executable section of the
PL/SQL block?
The respondent's email (null) was recorded on submission of this form. Mark only one oval.
* Required
NULL

1. Email * 0

Results in a compilation error

An exception will be raised

2.  PL/SQL is a – *
5. What is TRUE about PL/SQL functionalities? *
Mark only one oval.
Mark only one oval.
Brick Structured Language

Block Structured Language Conditions and loops are fundamental elements of procedural languages like
PL/SQL.
Banner Structured Language
Various types and variables can be declared, as can procedures and functions, as
Build Structured Language well as types and variables of those types.

Arrays can be used with it as well as handling exceptions (runtime errors).

All of the above


3. Select invalid variable types *

Mark only one oval.


6. Which of the following is/are TRUE about PL/SQL Variables? *
A. CHAR

B. VARCHAR1 Mark only one oval.

C. VARCHAR2 Variables serve as a means for programmers to temporarily store data during code
D. INTEGER execution.

PL/SQL programs benefit from its use.

There is nothing special about it other than being the name of a storage area.

All of the above

https://docs.google.com/forms/d/1PHW2iLCOVtkBDAf_WSeElaSeF6IwNKC7d6z5Q1f5-ZE/edit 1/4 https://docs.google.com/forms/d/1PHW2iLCOVtkBDAf_WSeElaSeF6IwNKC7d6z5Q1f5-ZE/edit 2/4


5/23/22, 2:22 AM Unit 5 Quiz 5/23/22, 2:22 AM Unit 5 Quiz

7. In ................... the cursor advances to the next row in the active set each time the * 11. The variables in the triggers are declared using *
fetch command is executed.
Mark only one oval.
Mark only one oval.
-
recreating process @
redefining process /
iterative process /@
None of the above

8. 1. A __________ is a special kind of a store procedure that executes in response *


to certain action on the table like insertion, deletion or updation of data This content is neither created nor endorsed by Google.

Mark only one oval.


 Forms
Procedures

Triggers

Functions

None of the mentioned

9. Triggers ________ enabled or disabled *

Mark only one oval.

Can be

Cannot be

Ought to be

Always

10. What are the after triggers ? *

Mark only one oval.

Triggers generated after a particular operation

These triggers run after an insert, update or delete on a table

These triggers run after an insert, views, update or delete on a table

https://docs.google.com/forms/d/1PHW2iLCOVtkBDAf_WSeElaSeF6IwNKC7d6z5Q1f5-ZE/edit 3/4 https://docs.google.com/forms/d/1PHW2iLCOVtkBDAf_WSeElaSeF6IwNKC7d6z5Q1f5-ZE/edit 4/4


4. Mid Semester Test Papers
5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021 5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021

5. The overall design of the database is called the database


MST 1 - CS 502 DBMS July Dec 2021 Mark only one oval.

The respondent's email (null) was recorded on submission of this form. Instance
* Required
Physical structure

Schema
1. Email *
Logical structure

6. Data independence is the type of data transparency that matters for a


2. Enrollment Number * centralized DBMS

Mark only one oval.

True

3. Name * False

7. Relational Database Management System consists of:


4. Section * Mark only one oval.
Mark only one oval.
A Schema

1 A set of tables

2 Both schema and set of tables

8.  ................... is a collection of processes that facilitate the designing, development,


implementation and maintenance of enterprise data management systems.
Quiz Questions
Mark only one oval.

Database design

Database

DBMS

Algorithm

https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 1/14 https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 2/14


5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021 5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021

9. A primary key ____. 12. __________ of abstraction explains how data is actually stored and describes *
the Data Structure and Access methods used by the database.
Mark only one oval.
Mark only one oval.
Is a minimal superkey
View level
Is always the first field in each table
Physical level
Must be numeric
Logical level
Must be unique
None of the mentioned

10.  The referential integrity rule requires that ____.


13. In _______________________ model the data is represented as relations
Mark only one oval.
Mark only one oval.
Every null foreign key value must reference an existing primary key value
Network model
An attribute have a corresponding value
Unifying model
Every non-null foreign key value reference an existing primary key value
Relational model
You delete a row in one table whose primary key does not have a matching foreign
Hierarchical model
key value in another table

14. An entity that depends on another entity called a


11. A key that can be uniquely used to identify a database record, that may contain
extra attributes that are not necessary to uniquely identify records. Mark only one oval.

Mark only one oval. Weak entity

Candidate key. Key

Super Key Dependent entity

Primary key Strong entity

Foreign key

15. If an entity appears in N relationship then it is

Mark only one oval.

1:1 relationship

1:N relationship

N:1 relationship

N:M relationship

https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 3/14 https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 4/14


5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021 5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021

16. The process in which tuple is created by having combined attributes from two 19. Pick entities from the following:  (i) vendor  (ii) student  (iii) attends  (iv) km/hour
relations is classified as
Mark only one oval.
Mark only one oval.
i,ii,iii
Cartesian compatibility i,ii,iv
Cartesian multiples i and ii
Cartesian product iii and iv
Cartesian ordinate

20. __________ of abstraction explains how data is actually stored and describes the
17. Consider two tuples B and C, the operation whose result includes tuples that Data Structure and Access methods used by the database
are included in both relations or either in B or C is classified as
Mark only one oval.
Mark only one oval.
View level
Square of relation B and C Physical level
Union of relation B and C Logical level
Intersection of relation B and C None of the mentioned
Difference of relation B and C

21. In the ER diagram, an entity can be represented as


18. ......... is used to represent the relationship. *
Mark only one oval.
Mark only one oval.
Diamond
Eclipse Square
Rectangle Rectangles
Line Triangles
Diamond

https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 5/14 https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 6/14


5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021 5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021

22. In unary relational operations, the SELECT operation is partition of relation * 25. The DIVISION operation can be applied to two relations A and B such as R(A) ÷ *
usually classified as R(B) where as

Mark only one oval. Mark only one oval.

Horizontal partition A does not belong to B

Vertical partition A must be added to B

Insert partition A belongs or equal to B

Delete partition A must be subtracted from B

23. The operators in SELECT operation statement such as and , or and not are * 26. The Boolean expression used in the SELECT operation consists of clauses such *
classified as as

Mark only one oval. Mark only one oval.

Boolean operators Attribute name

Tuple operators Constant value

String operators Comparison operators

Insertion operators All

24. If in the JOIN operation, the conditions of JOIN operation are not satisfied * 27. The operation which allows to process relationships from multiple relations *
then the results of the operation is rather than single relation is classified as

Mark only one oval. Mark only one oval.

Zero tuples and empty relation Division operation

One tuple from one relation Relation operation

Zero tuples from two relation Square operation

Two tuples from empty relations Join operation

https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 7/14 https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 8/14


5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021 5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021

28. If matching tuples are not found, the kind of OUTER JOIN operation which * 31. The JOIN operation which uses any of the comparison operators is classified *
keeps all the tuples of first and second relation is classified as as

Mark only one oval. Mark only one oval.

LEFT OUTER JOIN THETA JOIN

FULL OUTER JOIN CHI-JOIN

HALF OUTER JOIN PI-JOIN

DOWNWARD JOIN SIGMA-JOIN

29. The operations which are used to enhance the power of expression of * 32. The kind of operation by which one tuple can be created with the help of *
relational algebra includes combining tuples from two relations is classified as

Mark only one oval. Mark only one oval.

Generalized projection Square operation

Recursive closure operations Join operation

Outer JOIN operations Division operation

All of the mentioned Relation operation

30. In unary relational operations, the symbols such as equal to, less than and * 33. Consider two tuples X and Y, the operation whose result includes tuples that *
greater than are classified as are only in X but not in Y is classified as

Mark only one oval. Mark only one oval.

Tuple operators Square of relation X and Y

Column operators Union of relation X and Y

Comparison operators Intersection of relation X and Y

Row operators Difference of relation X and Y

https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 9/14 https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 10/14


5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021 5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021

34. The expression used in relational calculus to specify request of retrieval is * 37. The operations used to combine multiple relations to present information in *
classified as single table are classified as

Mark only one oval. Mark only one oval.

Declarative expression Outer relations

Procedural expression Inner joins

Structural expression Outer joins

Functional expression Inner relations

35. The compatibility condition which states that the relations for union and * 38. In unary relational operations, the PROJECT operation is partition of relation *
intersection operations must consist of same type of tuples is classified as usually classified as

Mark only one oval. Mark only one oval.

Union compatibility Horizontal partition

Intersect compatibility Vertical partition

Row compatibility Insert partition

Column compatibility Delete partition

36. If the common attributes of two relations are classified as join attributes then * 39. The JOIN operation in which two attributes joined have same name in both *
the OUTER UNION must be equal to relations is classified as

Mark only one oval. Mark only one oval.

LEFT OUTER JOIN UNNATURAL JOIN

FULL OUTER JOIN THETA JOIN

HALF OUTER JOIN ALPHA JOIN

DOWNWARD JOIN NATURAL JOIN

https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 11/14 https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 12/14


5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021 5/23/22, 2:30 AM MST 1 - CS 502 DBMS July Dec 2021

40. Consider two tuples A and B, the operation whose result includes tuples that * 43. If matching tuples are not found, the kind of OUTER JOIN operation which *
are included in both relations is classified as keeps all the tuples of first relation out of the two relations is classified as

Mark only one oval. Mark only one oval.

Intersection of relation A and B LEFT OUTER JOIN

Difference of relation A and B RIGHT OUTER JOIN

Square of relation A and B UPWARD JOIN

Union of relation A and B DOWNWARD JOIN

41. The operation which is used to select the subset of tuples by satisfying the * 44. The operation which only selects some of the columns from table and neglect *
selection constraint and the selection is made from relation is classified as the remaining columns is classified as

Mark only one oval. Mark only one oval.

CHOOSE operation OR operation

SELECT operation AND operation

NON-SELECT operation TABLE operation

SUBSET operation PROJECT operation

42. If matching tuples are not found, the kind of OUTER JOIN operation which *
keeps all the tuples of second relation out of the two relations is classified as
This content is neither created nor endorsed by Google.
Mark only one oval.

UPWARD JOIN  Forms

DOWNWARD JOIN

LEFT OUTER JOIN

RIGHT OUTER JOIN

https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 13/14 https://docs.google.com/forms/d/1pNnJwNymYgyE0eIZBfpM76MokTt9uNB9q-Nyk4hPuu0/edit 14/14


5/23/22, 2:31 AM DBMS MST 2 Examination 5/23/22, 2:31 AM DBMS MST 2 Examination

5. If every functional dependency in set E is also in the closure of F then this is


DBMS MST 2 Examination classified as

Mark only one oval.


The respondent's email (null) was recorded on submission of this form.
* Required FD is covered by E

E is covered by F
1. Email * F is covered by E

F+ is covered by

2. Name * 6. In standard query language, the rows and columns are called respectively

Mark only one oval.

tuple and attributes

3. Enrollment Number * quantifiers and identifiers

predicator and indicator

non-identifiers and quantifier

4. Section *

Mark only one oval. 7. The clause used in SQL for ensuring referential integrity is classified as

Mark only one oval.


CS 1

CS 2 PRIMARY KEY clause

CS 3 SECONDARY KEY clause

CS 4 FOREIGN KEY clause

INTERVAL KEY clause

Quiz Questions

https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 1/14 https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 2/14


5/23/22, 2:31 AM DBMS MST 2 Examination 5/23/22, 2:31 AM DBMS MST 2 Examination

8. The command used in SQL which deletes the table definition as well as all the 11. The ____ connective tests for set membership, where the set is a collection of
records available in the table is called values produced by a select clause. The ____ connective tests for the absence
of set membership.
Mark only one oval.
Mark only one oval.
DELETE command

DROP TABLE command Or, in

PRIMARY KEY command Not in, in

SECONDARY KEY command In, not in

In, or

9. Select ________ dept_name from instructor;  Here which of the following displays
the unique values of the column ? 12. If there is more than one key for relation schema in DBMS then each key in
Mark only one oval. relation schema is classified as

Mark only one oval.


All

From prime key

Distinct super key

Name candidate key

primary key

10. Aggregate functions are functions that take a ___________ as input and return a
single value. 13. The property of normalization of relations which guarantees that functional
Mark only one oval. dependencies are represented in separate relations after decomposition is
classified as
Collection of values
Mark only one oval.
Single value

Aggregate value non-additive join property

Both Collection of values & Single value independency reservation property

dependency preservation property

additive join property

https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 3/14 https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 4/14


5/23/22, 2:31 AM DBMS MST 2 Examination 5/23/22, 2:31 AM DBMS MST 2 Examination

14. The rule which states that addition of same attributes to the right side and left 17. The procedure of storing higher normal form relations which are in lower normal
side will results in other valid dependency is classified as form as a base relation is classified as

Mark only one oval. Mark only one oval.

referential rule isolation of data

inferential rule de-normalization of data

augmentation rule normalization of data

reflexive rule denomination of data

15. The process of analyzing relation schemas to achieve minimal redundancy and 18. In the reflexive rule (IR1), the true dependencies generated are classified as
insertion or update anomalies is classified as Mark only one oval.
Mark only one oval.
trivial

normalization of data nontrivial

denomination of data inferential

isolation of data functional

de-normalization of data

19. In normalization of relations, the property which is critical and must be achieved
16. Considering the relational database, the functional dependency between two is classified as
attributes A and B is denoted by Mark only one oval.
Mark only one oval.
nonadditive join property

A→B additive join property

B←A independency reservation property

AB → R dependency preservation property

R ← AB

https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 5/14 https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 6/14


5/23/22, 2:31 AM DBMS MST 2 Examination 5/23/22, 2:31 AM DBMS MST 2 Examination

20. The normalization form which is based on the transitive dependency is 23. The rule that always generate true dependencies is called
classified as
Mark only one oval.
Mark only one oval.
referential rule
first normal form inferential rule
second normal form closure rule
fourth normal form reflexive rule
third normal form

24. Given FD's are AB -> C, C -> DE, E ->F and F -> A, find highest Normal Form *
21. The normal form which only includes indivisible values or single atomic values is
Mark only one oval.
classified as
1NF
Mark only one oval.
2NF
third normal form
3NF
first normal form
BCNF
second normal form

fourth normal form

25. Find the normal forms in following Schemas : Registration (rollno, courses) and
FD {rollno -> courses} and rollno is a key attribute
22. The concept in normalization of relations which is based on the full functional
Mark only one oval.
dependency is classified as
1NF
Mark only one oval.
2NF
fourth normal form
3NF
third normal form
BCNF
first normal form

second normal form

https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 7/14 https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 8/14


5/23/22, 2:31 AM DBMS MST 2 Examination 5/23/22, 2:31 AM DBMS MST 2 Examination

26. ........ means that a transaction must make its changes permanent to the 29. When the transaction finishes the final statement the transaction enters into
database ends.
Mark only one oval.
Mark only one oval.
Active state
Isolation Committed state
Locking Partially committed state
Durability Abort state
Consistency

30. Which of the following is an atomic sequence of database actions?


27. Throughput means
Mark only one oval.
Mark only one oval.
Transaction
Number of transactions that is committed in one hour Concurrency
Number of operations in a transaction Relations
Number of transaction that can be aborted in a given amount of time All of the mentioned
Number of transaction that can be executed in a given amount of time

31. Will undo all statements up to commit?


28. ......... protocol is used to perform multiple transactions that execute on different
Mark only one oval.
database.
Transaction
Mark only one oval.
Flashback
Commit
Rollback
Two phase lock
Abort
Two phase commit

Locking

32. State true or false: Using checkpoints reduces overhead

Mark only one oval.

True

False

https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 9/14 https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 10/14


5/23/22, 2:31 AM DBMS MST 2 Examination 5/23/22, 2:31 AM DBMS MST 2 Examination

33. In dirty read problem....... 36. Cascading rollback is avoided in all protocol except

Mark only one oval. Mark only one oval.

One transaction reads an uncommitted value of another transaction Strict two-phase locking protocol.

One transaction reads the committed value for another transaction Tree locking protocol

One transaction reads another transaction Two-phase locking protocol

One transaction commits another transaction. Validation based protocol.

34. A transaction can do only read operation and not write operation on a data item
37. If a transaction T has obtained an exclusive lock on item Q, then T can
when it acquires ....... lock.
Mark only one oval.
Mark only one oval.
read Q
Read mode
write Q
Exclusive mode
both read and write Q
Shared mode
write Q but not read Q
Write mode

38. Wait-for graph is used for


35. Assume transaction A holds a shared lock R. If transaction B also requests for a
shared lock on R Mark only one oval.

Mark only one oval. Detecting view serializability.

Detecting conflict serializability.


It will result in a deadlock situation
Deadlock prevention
It will immediately be rejected
Deadlock detection
It will immediately be granted

It will be granted as soon as it is released by A

39. A ....... contains information for undoing or redoing all the actions performed by
the transactions.

Mark only one oval.

savepoint

log

node

commit_point

https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 11/14 https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 12/14


5/23/22, 2:31 AM DBMS MST 2 Examination 5/23/22, 2:31 AM DBMS MST 2 Examination

40. In .........., one or more users/programs attempt to access the same data at the 43. Consider the following transactions with data items P and Q initialized to zero:    
same time.   T1: read (P); read (Q) ;          if P = 0 then Q : = Q + 1 ;      write (Q) ;        T2: read
(Q) ;  read (P) ;      if Q = 0 then P : = P + 1 ;    write (P) ;
Mark only one oval.
Mark only one oval.
Concurrency

Transaction control A serializable schedule

Locking A schedule that is not conflict serializable

Two phase locking A conflict serializable schedule

A schedule for which a precedence graph cannot be drawn

41. Isolation of the transactions is ensured by


44.  Consider the following schedules involving two transactions. Which one of the
Mark only one oval.
following statement is true?     S1: R1(X) R1(Y) R2(X) R2(Y) W2(Y) W1(X)             S2:
Transaction management R1(X) R2(X) R2(Y) W2(Y) R1(Y) W1(X)
Application programmer Mark only one oval.
Concurrency control
Both S1 and S2 are conflict serializable
Recovery management
Only S1 is conflict serializable

Only S2 is conflict serializable

None
42. I and J are _________ if they are operations by different transactions on the
same data item, and at least one of them is a write operation.

Mark only one oval.

Conflicting
This content is neither created nor endorsed by Google.
Overwriting

 Forms
Isolated

Durable

https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 13/14 https://docs.google.com/forms/d/1sF_Ze1gCOk9iBz9mmghU8mfsgrncNSZfIH4irszU9Lg/edit 14/14


5. Practical List
Available in Lab Manual

6. Schedule of Different Assessments


SNo Assessment Method Name Date Remarks
Given Due Extended
1 Unit Test 1 07th Sept 2021 - - -
2 Unit Test 1 26th Sept 2021
3 Unit Test 1 30th Oct 2021
4 Unit Test 1 27th Nov 2021
5 Unit Test 1 30th Nov 2021
6 MST 1 08th Oct 2021
7 MST 2 11th Nov 2021
8 Assignment 01st August 2021 30th Sept 2021 - -
9 Certification Oracle Academy Course 11th August 2021 05th Oct 2021 - -

D. Student Performance
1. Attendance Record
Attach daily attendance sheet of class for the subject taught.

2. Student Evaluation Sheet Containing Results of Different Assessment Tools


Attach student evaluation/assessment sheet of class for the subject taught.

3. University Results
Attach University result sheet of class for the subject taught.

4. Identification of Slow and Fast Learner Students and Action Taken

Slow learner Students List:


SNo Name Enrollment Number Remarks
1 ABHISHEK BAIRAGI 0827CS191005
2 ADITYA JOSHI 0827CS191010
3 ADITYA MISHRA 0827CS191011
4 AMAN GOUR 0827CS191029
5 DARSHAN SONI 0827CS191075
6 DEEPAK SHARMA 0827CS191078
7 MITESH DARDA 0827CS191152
8 NEELESH VAISHNAV 0827CS191164
9 RITIK PATIDAR 0827CS191191
10 SIDDHARTH LODHWAL 0827CS191231

Slow learner students are identified on the basis of Class participation and responsiveness and
performance of MST 1 Examination.
Initiative taken for Slow learner students:
a. Additional e-learning resources suggested through counseling.
https://www.youtube.com/watch?v=3EJlovevfcA
b. Highlighting important and frequently asked questions.
c. Personal attention

The performance analysis of slow learner as follow:


Before action taken:

S. Enrollment MST Marks1 Class participation


Name
No Number (20) and responsiveness
1 ABHISHEK BAIRAGI 0827CS191005 12 Poor
2 ADITYA JOSHI 0827CS191010 12 Poor
3 ADITYA MISHRA 0827CS191011 13 Poor
4 AMAN GOUR 0827CS191029 12 Poor
5 DARSHAN SONI 0827CS191075 12 Poor
6 DEEPAK SHARMA 0827CS191078 12 Poor
7 MITESH DARDA 0827CS191152 12 Poor
8 NEELESH VAISHNAV 0827CS191164 12 Poor
9 RITIK PATIDAR 0827CS191191 13 Poor
10 SIDDHARTH LODHWAL 0827CS191231 13 Poor

Improvement after action taken:

S. Enrollment MST Marks2 Class participation


Name
No Number (30) and responsiveness
1 ABHISHEK BAIRAGI 0827CS191005 26 Average
2 ADITYA JOSHI 0827CS191010 28 Above Average
3 ADITYA MISHRA 0827CS191011 24 Average
4 AMAN GOUR 0827CS191029 29 Above Average
5 DARSHAN SONI 0827CS191075 29 Average
6 DEEPAK SHARMA 0827CS191078 29 Average
7 MITESH DARDA 0827CS191152 28 Average
8 NEELESH VAISHNAV 0827CS191164 29 Above Average
9 RITIK PATIDAR 0827CS191191 27 Average
10 SIDDHARTH LODHWAL 0827CS191231 27 Above Average

Fast learner Students List:


SNo Name Enrollment No Remarks
1 AAKASH SIKARWAR 0827CS191002
2 ADITYA PAWAR 0827CS191012
3 AKSHAY SINGH BHADORIYA 0827CS191024
4 ARYAN DAME 0827CS191054
5 DARSH BHUTA 0827CS191073
6 DEEKSHA YADAV 0827CS191076
7 DEVANSH UPADHYAY 0827CS191082
8 HARSHIT KHARE 0827CS191105
9 MITESH KHEMANI 0827CS191153
10 PUNIT PARAKH 0827CS191180
11 RIYA GOYAL 0827CS191194
12 TUSHAR MODI 0827CS191251
13 YATI CHOURGADE 0827CS191273

Action taken for Fast learner Students List:


a. GATE Questions has been provided to more practice.
b. Provided SQL practice questions for interview purposes.
c. Encourage to participate in national level contests and events.

E. Continuous Improvement
1. Previous Semester Feedback
Attache copy of previous semester feedback received from faculty members teaching the subject.

2. Recommendations Based on Observations Made while Teaching the


Subject
a. More emphasis should be given to clear the concepts of ERD concepts and Relational Algebra
& Calculus.
b. Tutorials must be incorporated in the syllabus.

You might also like