Professional Documents
Culture Documents
Vision
To be an academic leader for the development of human potential so as to meet the global challenges.
Vision
The department strives to produce competent and qualified computer professionals and researchers to
serve the community and profession with moral values and ethics.
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.
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.
Scheme:
Contact
Practical
Theory Marks Hours per
Marks
week
Subject Name
Subject Code
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
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.
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.
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
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
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
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
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
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.
Text/Reference Books:
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}:
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]
https://www.rgpvonline.com
[3]
CS-502-CBGS PTO
https://www.rgpvonline.com
[4]
******
CS-502-CBGS PTO
https://www.rgpvonline.com
https://www.rgpvonline.com
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.
CS-5003-CBGS PTO
https://www.rgpvonline.com
https://www.rgpvonline.com
[2]
******
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
Lecture -1 Overview of
Subject
By: Narendra Pal Singh Rathore
www.acropolis.in
1 2
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
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.
7 8
Information
Employee Doctor’s Book’s
Product’s Data Data
Data
Data
Data Information
Information
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
13 14
15 16
17 18
3
5/25/2022
19 20
21 22
23 24
4
5/25/2022
25 26
Scheme Syllabus
27 28
Syllabus Syllabus
29 30
5
5/25/2022
31 32
33 34
35 36
6
5/25/2022
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 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
View definition-
The SQL DDL includes commands for defining views.
Transaction Control- SQL includes for specifying the beginning and ending of transactions.
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.
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));
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.
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.
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) );
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
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
By using this method we can add records or data to Sailors, Boats as well as Reserves
Table.
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;
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
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
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%’.
TO_CHAR (N [,FMT]) :- Converts ‘N’ of numeric data type to Varchar2 datatype using optional
number format FMT.
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:- 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.
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 2) Concat bid & bname of Boats & display along with color.
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.
LOWER(CHAR) :- Converts all characters to lowercase characters in a sting CHAR. Ex:- Display all
Boats information by showing their names in lower case.
UPPER(CHAR) :- Converts all characters to uppercase characters in a sting CHAR. Ex:- Display all
Sailors information by showing their names in Upper case.
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;
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’
2) Display length of string SID, SNAME from Sailors along with their values.
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.
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.
TRANSLATE(CHAR, FROM, TO) :- It returns characters with all occurrences of each character
in FROM replaced by its corresponding character in TO.
2) Display Sailors information by replacing ‘a’ with ‘i’ from SNAME, if any.
Date Functions :
Sysdate, next_day, add_months, last_day, months_between, least, greatest, trunc, round,
to_char, to_date.
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.
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;
Ex: Display SID, Day of Reservation and months between System Date & day of reservation. SQL>
SELECT SID, DAY, MONTHS_BETWEEN (SYSDATE, DAY) FROM RESERVES;
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.
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’;
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);
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)
Syntax:
SELECT columnname, columnname FROM tablename
GROUP BY columnname;
HAVING searchcondition;
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;
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.
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.
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);
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);
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’.
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.
Composite Index:-
Syntax:-
CREATE INDEX index_name
ON tablename(columnname,columnname);
Example:
CREATE INDEX VERI_SID ON SAILORS (SID,AGE);
Dropping Indexes:-
An index can be dropped by using DROP INDEX
SYNTAX:-
DROP INDEX indexfilename;
Example:-
DROP INDEX VERI_SID;
Type of Index
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:
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.
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.
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.
Conclusion:
DCL statements are used to provide data sharing of data in database.
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.
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.
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
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:
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
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;
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.
Example:
Here we are going to create a procedure that will check the rating of SAILOR
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.
Example:
Here we are going to create a function that will check the rating of SAILOR
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
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.
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.
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.
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.
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;
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.
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.
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)
REG_NO VARCHAR2(12)
STU_NAME VARCHAR2(25)
DEPT VARCHAR2(4)
BATCH VARCHAR2(9)
REG_NO VARCHAR2(12)
STU_NAME VARCHAR2(25)
BOOK_NO VARCHAR2(6)
BOOK_NAME VARCHAR2(35)
DDATE DATE
REG_NO VARCHAR2(12)
STU_NAME VARCHAR2(25)
BOOK_NO VARCHAR2(6)
BOOK_NAME VARCHAR2(35)
DDATE DATE
RDATE DATE
Result :
Thus the procedure for library management system was written and executed.
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)
ACCNO NUMBER(15)
ACCNAME VARCHAR2(20)
TRANSDATE DATE
TRANSTYPE VARCHAR2(1)
AMT NUMBER(10)
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
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
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.
Result:
Thus the procedure for bank process was written and executed.
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.
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.
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
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";
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
Conclusion:
Referring to the problem statement the ER diagram was designed and converted into the tables.
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)
• 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.
• 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.
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:
f) Degree of relation
g) Aggregation
h) Physical schema
b) Professors can teach the same course in several semesters and only the most recent such
offering needs to be recorded.
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:
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)
c) Get Supplier number who supply quantity greater than average quantity
27. Consider the following relational schema Employee (empno, name, office, age)
Books (isbn, title, authors, publisher) Loan (empno, isbn, date)
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)
29.Consider the relational database given below. Give expressions in QBE and for each of the following
queries.
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.
NAME :
CLASS :
DBMS Unit 1
DATE :
25 Questions
1. The conceptual schema defines the view or views for particular users.
A True B False
C Oracle D SQL
A Retrieval of information stored in the database B Insertion of new information into the database
A schema B instance
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.
https://quizizz.com/print/quiz/6135ab1d54e8a4001d7c6441 1/3
5/23/22, 2:11 AM DBMS Unit 1
9. Data independence is the type of data transparency that matters for a centralized DBMS
A False B True
12. The set of relations and set of domains that defines the way data can be represented as ______________________
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.
C Algorithm D DBMS
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
A Diamond B Circle
C Eclipse D Rectangle
21. An attribute can have more than one value are known as a .........
22. An attribute that can be derived from other attribute is known as a .........
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.
25. Which one of the following refers to the total view of the database content?
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
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
Mark only one oval. 7. The DIVISION operation can be applied to two relations A and B such as * 1 point
A belongs or equal to B
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
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
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
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
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
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
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
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
PI-JOIN
LEFT OUTER JOIN
SIGMA-JOIN
FULL OUTER JOIN
EQUI JOIN
HALF OUTER JOIN
DOWNWARD JOIN
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
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
28. Consider two tuples A and B, the operation whose result includes tuples * 1 point
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
32. The operation which only selects some of the columns from table and * 1 point
neglect the remaining columns is classified as
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
Cartesian compatibility
Cartesian multiples
Cartesian product
Cartesian ordinate
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
The respondent's email (null) was recorded on submission of this form. tuple and attributes
* Required
quantifiers and identifiers
6. The clause used in SQL for ensuring referential integrity is classified as * 1 point
2. Name *
Mark only one oval.
Quiz Questions
7. The command used in SQL which deletes the table definition as well as all * 1 point
F+ is covered by
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
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
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.
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
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
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
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
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
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
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
Transaction
Flashback
Rollback
Abort
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.
Transaction control
Locking
9. In dirty read problem....... *
Two phase locking
Mark only one oval.
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.
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
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) ;
A serializable schedule
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)
None
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
1. Email * 0
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.
C. VARCHAR2 Variables serve as a means for programmers to temporarily store data during code
D. INTEGER execution.
There is nothing special about it other than being the name of a storage area.
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
Triggers
Functions
Can be
Cannot be
Ought to be
Always
The respondent's email (null) was recorded on submission of this form. Instance
* Required
Physical structure
Schema
1. Email *
Logical structure
True
3. Name * False
1 A set of tables
Database design
Database
DBMS
Algorithm
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
Foreign key
1:1 relationship
1:N relationship
N:1 relationship
N:M relationship
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
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
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
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
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
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
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
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
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
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
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
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
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.
DOWNWARD JOIN
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
4. Section *
Mark only one oval. 7. The clause used in SQL for ensuring referential integrity is classified as
Quiz Questions
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
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
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
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
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
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
R ← AB
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
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
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
Locking
True
False
33. In dirty read problem....... 36. Cascading rollback is avoided in all protocol except
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
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
39. A ....... contains information for undoing or redoing all the actions performed by
the transactions.
savepoint
log
node
commit_point
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
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.
Conflicting
This content is neither created nor endorsed by Google.
Overwriting
Forms
Isolated
Durable
D. Student Performance
1. Attendance Record
Attach daily attendance sheet of class for the subject taught.
3. University Results
Attach University result sheet of class for the subject taught.
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
E. Continuous Improvement
1. Previous Semester Feedback
Attache copy of previous semester feedback received from faculty members teaching the subject.