You are on page 1of 110

www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.

in

Database Management System

DBMS
BSC (MSCS,MPCS)
SEM – IV
BY

CS-SIR
C.AMBADAS

B.Sc II Year IV Sem C.AMBADAS Page 1

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


SYLLABUS

Unit - I
Introduction: Database-System Applications, Purpose of Database Systems, View of Data,
Database Languages, Relational Databases, Database Design, Data Storage and Querying,
Transaction Management, Database Architecture, Database Users and Administrators.
Introduction to the Relational Model: Structure of Relational Databases, Database Schema,
Keys, Schema Diagrams, Relational Query Languages, Relational Operations.

Unit - II
Database Design and the E-R Model: Overview of the Design Process, The Entity- Relationship
Model, Constraints, Removing Redundant Attributes in Entity Sets, Entity- Relationship Diagrams,
Reduction to Relational Schemas, Entity-Relationship Design Issues, Extended E-R Features,
Alternative Notations for Modeling Data, Other Aspects of Database Design.
Relational Database Design: Features of Good Relational Designs, Atomic Domains and First
Normal Form, Decomposition Using Functional Dependencies, Functional- Dependency Theory,
Decomposition Using Multivalued Dependencies, Normal Forms-2 NF, 3 NF, BCNF, The
Database Design Methodology for Relational Databases.

Unit - III
Introduction to SQL: Overview of the SQL Query Language, SQL Data Definition, Basic Structure
of SQL Queries, Additional Basic Operations, Set Operations, Null Values, Aggregate Functions,
Nested Subqueries, Modification of the Database.
Intermediate SQL: Join Expressions, Views, Transactions, Integrity Constraints, SQL Data Types
and Schemas, Authorization.
Advanced SQL: Accessing SQL from a Programming Language, Functions and Procedures,
Triggers, Recursive Queries.

Unit - IV
Transaction Management: Transaction Support–Properties of Transactions, Database Architecture,
Concurrency Control–The Need for Concurrency Control, Serializability and Recoverability,
Locking Methods, Deadlock, Time Stamping Methods, Multi-version Timestamp Ordering,
Optimistic Techniques, Granularity of Data Items, Database Recovery– The Need for Recovery,
Transactions and Recovery, Recovery Facilities, Recovery Techniques, Nested Transaction Model.
Security: Database Security–Threats, Computer- Based Controls–Authorization, Access Controls,
Views, Backup and Recovery, Integrity, Encryption, RAID.

Text book:
1. Silberschatz, H. Korth and S. Sudarshan, Database System Concepts, 6th Ed., Tata
McGraw Hill, 2011
2. Thomas M. Connolly, Carolyn E. Begg, Database Systems–A Practical Approach to
Design, Implementation, and Management (6e)

B.Sc II Year IV Sem C.AMBADAS Page 2

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


UNIT-I
INTRODUCTION TO DBMS
Data:- Data is a raw collection of facts about people, places and objects and events,
which include text, numbers, graphics, images, sound etc that have meaning in the
user's environment.

Information:- Information is processed data in an organized or summarized form. It is


given by the computer when user requests.

Database:- It is a collection of logically related data that can be processed by application


programs. A database has several database elements like table, queries, stored
procedures and etc.

Database management system: A DBMS is a collection of interrelated data& set of


programs to store access these data in easily and effective manner.

DBMS is a set of database and application programs that allow us to create,


maintain and access the database.

Q) Explain Applications of DBMS?

Railway reservation system: Data base is required to keep record of ticket booking,
Train departure and arrival status. Also if trains get late then people get to know it
through database update.
Library management: There are thousands of books in a library, so it is very difficult
to keep record of all the books in a copy or register. so, DBMS used to maintain all the
information relate to book issue data name of the book, author and availability of the
book.
Banking: We make thousands of transaction through banks daily and we can do this
without going to the bank. so how banking has become so easy that by sitting at name
we can send or get money through banks that is all possible just because of DBMS that
manages all the bank transactions.
University & Colleges: Examinations are done online to day and universities and
colleges maintain all these records through DBMS. Student registration details, courses
and grades are stored in data base.
Credit card transactions: For purchase of credit cards and all the other transactions
are made possible by DBMS. A credit card holder knows the importance of their
information that all are secured through DBMS.
Social media sites: We are all on social media websites to share our views and
connect with our friends. Daily millions of users signed up for the social media accounts
like face book, twitter, pinterest , google plus , etc…
But how all the information‟s of users are stored and how we become able to connect to
other people, yes this is all because of “DBMS”.
Tele communications: Any tele communication company cannot everything about
their business without DBMS. It is must for these companies to store the call details and
monthly passed paid bills.

B.Sc II Year IV Sem C.AMBADAS Page 3

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Military: Military keeps records of millions of soldiers and it has millions of files that
should be keep secure and safe DBMS provides a big security assurance to the military
information one can easily search for all the information about anyone within seconds
with the help of DBMS.
Online shopping: Online shopping has became a big trend of these days, No one
wants to go shops, and waste their time, everyone wants to shop from home so, all the
products are added and sold only with the help of DBMS.
Human resource Management: Big firm have many workers working under them
HRM department keeps records of employee‟s salary, tax, and work through DBMS.
Manufacturing: companies makes products and sale them on the daily bases to keep
records of all the details about the products like quantity, bills, purchase, supply chain
management, DBMS is used.
Airline reservation system: Same as the railway reservation system, airline also
needs DBMS to keep records of flights arrivals, departure and delay status.
Q) Purpose of the data base system?
In 1960‟s consider part of bank example:
 To see why database management systems are necessary, file processing system
supported by a conventional operating system.
The applications is a savings bank:
saving account and customer records are kept in permanent system files
Application programs are written return to manipulate files to perform the following
tasks.
o Debit or credit an account.
o Add a new account.
o Find an account balance.
o Generate monthly accounts.
Development of the system proceeds as follows:
New application programs must be written as the needs.
New permanent files are created as required.
But over a long period of time files may be different formats
Application programs may be in different languages.
This typically file processing system supported by a conventional operating system. In a
file processing system has number of major disadvantages.

File based Systems:-

A file based system is a collection of application programs that perform services for the
users wishing to access information. Each program within a file based system defines
and manages its own data. Because of this, there are limits as to how that data can be
used or transported.
Limitations of File based system:

1. Data Duplication:

Each program stores its own supported files . The same data accessed by different
programs, then each program must store its own copy of the same data.

B.Sc II Year IV Sem C.AMBADAS Page 4

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


2. Difficult implement data security:-

Data is stored in different files by different application programs . This makes it difficult
and expensive to implement security on data.

3. Limited Data Sharing:-

With the traditional file processing system each application has its own private files and
users have little opportunities to share data outside this own application.

4. Data dependency : Here, any change to a file structure, forces modifications in all of
the programs that use the data in that file. And these modifications are likely to produce
errors.

5. System maintenance is difficult:

As the number of files in the system expands, system administration becomes more
difficult.

6. It cannot handle queries::-

File system cannot handle unplanned or complex queries.

For example: to generate a report, programmer needs to write a lengthy program.

Advantages of DBMS:

The DBMS has a no. of advantages as compared to traditional file based processing
approach.

1. Data Independence:

The separation of data description from the application programs that use the data is
called data independence.

This allows an organization's data to change without changing the application programs
that process the data.

2. Minimal Data Redundancy:

In non- database system each application program has its own private files in this case,
the duplicated copies of the same data are created in many places.

In DBMS all data of an organization integrated into a single database file, the data is
recorded in only one place in the database & it is not duplicated.

3. Minimized data inconsistency:

By controlling the data redundancy the data consistency is obtained. If a data item
appears only once, any update to its value has to be performed only once & the updated
value is immediately available to all users if the DBMS has controlled redundancy the
database system enforces consistency.
For example: If a customer address is stored only once, updating that becomes simple.
B.Sc II Year IV Sem C.AMBADAS Page 5

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


4.Enforcement standards: These standards will include naming convection, data
quality standards and processers for accessing, updating and protecting data.
5. Improved Data Sharing:

A database is designed as a shared resource. Authorized users are granted permission to


use database and each user is provided one or more user views. The DBMS provides
better access to data and better managed data.

6. Integrity can be maintained: The data values stored in the database must satisfy
certain types of consistency rules.

For example: The balance of a bank account may never fall below a particular amount
to define integrity constraints to the data in the data base.
7.Security can be enforced: Not every user should be able to access all the data. A data
base can be accessed only while proper authentication usually by verifying login and
password.
8. Improved data access:

The DBMS makes it possible to produce quick answers to any queries. A query is a
request or a question put to the DBMS for data manipulation or retrieval. Without any
programming experience, one can retrieve and display data very easily.

9.Backup and Recovery Procedure:

In computers file based system, the user creates the backup of data regularly to protect
the valuable data from damage due to the computer system (or) application program it is
very time consuming method, if the amount of data is large.

Q) View of data: or Abstract view of the data?

In the above diagram:

B.Sc II Year IV Sem C.AMBADAS Page 6

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


o It shows the DBMS architecture.
o Mapping is used to transform the request and response between various database
levels of architecture.
o Mapping is not good for small DBMS because it takes more time.
o In External / Conceptual mapping, it is necessary to transform the request from
external level to conceptual schema.
o In Conceptual / Internal mapping, DBMS transform the request from the
conceptual to internal level.
o External schema- Individual users view
o Conceptual schema- logical users view
o Physical schema – Internal view

1. Internal Level
o The internal level has an internal schema which describes the physical storage
structure of the database.
o The internal schema is also known as a physical schema.
o It uses the physical data model. It is used to define that how the data will be
stored in a block.
o The physical level is used to describe complex low-level data structures in detail.
o This level is at the bottom level architecture of DBMS.

2. Conceptual Level
o The conceptual schema describes the design of a database at the conceptual level.
Conceptual level is also known as logical level.
o The conceptual schema describes the structure of the whole database.
o The conceptual level describes what data are to be stored in the database and also
describes what relationship exists among those data.
o In the conceptual level, internal details such as an implementation of the data
structure are hidden.
o Programmers and database administrators work at this level.

3. External Level
o An external schema is also known as view schema.
o In the external level, a database contains several schemas that sometimes called
as subschema. The subschema is used to describe the different view of the
database.
o In the external level there are the 'n' number of external end users who can view
the data from the database.
o In this level the required data is provided to the end users. Because there is no
need to know about the all data structure from the database. The users need only
that data which is required.
o The data can be viewed uniquely as separately by the users as viewers.
o The external level is at the top level in the architecture of DBMS.

B.Sc II Year IV Sem C.AMBADAS Page 7

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Q) Discuss about data base languages?
Data definition languages(DDL) :
 A database schema is a set of definitions expressed by a special language called
DDL (Data definition language).
 The result of compilation DDL statements is a set of tables that is stored in special
file called data dictionary.
 A data dictionary is a file that contains metadata i.e., data about data.
 DDL commands are used to define a data base, include, creating, altering and
dropping tables and establishing constraints.

Create To create data base objects such as table &views


Alter To alter the structure of data base object
Drop To delete the DB object
Rename To rename the DB object
2.Data manipulation language (DML):-
 DML commands are used to maintain and access a data base including updating,
inserting, modifying and querying data.
Select To retrieve data from a table it allows filtering
Inset To insert data into a table
Update To update the values of attributes
Delete To delete rows from table

There are basically two types


1. Procedural DML:- Require a user to specify what data is needed and how to get
those data.
2. Non-procedure DML:- Require a user to specify what data are needed without
specifying how to get those data.
A query is a statement requesting the retrieval of information is called query
language.

Fourth-Generation Languages (4GL): 4GL is a non-procedural language.


Fourth-generation languages encompass:

• Presentation languages: such as query languages and report generators.


• Specialty languages: such as spreadsheets and database languages.
• Application generators: that defines, insert, update, and retrieve data
from the database to build applications.
• Very high-level languages: that is used to generate application code.

Q) Relational Database?
A relational database is based on the relational model and uses a collection of
tables to represent both data and the relationships among those data. It also
includes a Data-Manipulation Language, Data- Definition Language and Database
access from application programs.

1) Tables: Each table has multiple columns and each column has a unique
name. Each table contains records of a particular type. Each record type defines a
B.Sc II Year IV Sem C.AMBADAS Page 8

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


fixed number of fields or attributes. The columns of the table correspond to the
attributes of the record type.

2) Data Manipulation Language (DML): DML commands are used to maintain


and access a database, including updating, inserting, modifying, and querying
data. It deals with data.
The commands are: SELECT, INSERT, UPDATE and DELETE.

3) Data Definition Language (DDL): DDL commands are used to define a


database, including creating, altering, and dropping tables and establishing
constraints. DDL deals with metadata.
The commands are: CREATE, ALTER, DROP, TRUNCATE and RENAME.

4)Database Access from Application Programs: Database application programs


are programs that are used to interact with the database in this fashion.

By providing an application program interface (set of procedures) that can be


used to send DML and DDL statements to the database and retrieve the results.
The Open Database Connectivity (ODBC) standard for use with the C language is a
commonly used application program interface standard. The Java Database
Connectivity (DBC) standard provides corresponding features to the Java language.
By extending the host language syntax to embed DML calls within the host
language program.

Q)what is Data base design? Explain about DB design process?


Data base design is a collection of process that facilitate the designing, development,
implementation and maintenance of enterprise data management system.

It helps to produce data base systems.


1. That meet the requirement of user
2. Have high performance
The main objectives of data base design to produce logical and physical designs of
proposed data base systems.
The logical model concentrates on the data requirements and the data is to be stored
independent of physical consideration.
Physical model involves translating the logical design of database onto physical media
using hardware resources and software systems, such as DBMS.

Design process:- data base designing is a cruel to high performance database system.

Requirement analysis
B.Sc II Year IV Sem C.AMBADAS Page 9

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


 Planning: Planning of entire DB development life cycle it takes into consideration
the information system strategy of the organization.
 System definition: It defines the scope and boundaries of the proposed database
system.
Data base designing
 Logical model:- Developing a data base model based on requirements. The entire
design is on paper without any physical implementation (or) specific DBMS
consideration.
 Physical model:- This stage implements the logical model of database taking into
account the DBMS.
Implementation:
 Data conversion and loading:- This storage importing and converting data from
the old system into the new data base.
 Testing :- This phase is considered with identification of errors in newly
implemented system. It checks the data base against requirement specifications.

Q) Data storage and Querying ?


The database system is divided into two components, i.e
 Storage Manager
 Query Processor
Storage Manager
It is the component of a database system that provides an interface between the low-
level data stored, application programs and queries submitted to the system.
The storage manager is incharge of interactions with the file manager. Raw data is
stored on the disk using the file system provided by the operating system. It
translates various DML statements into Low-level commands.
The storage manager components include:

Authorization and Integrity Manager: Tests for the satisfaction of integrity constraints
and checks the authority of users to access data.
Transaction Manager: Ensures that the database remains in a uniform state despite
system failures where the ongoing transaction executions proceed without conflict.
File Manager: Manages the allocation of space on disk storage and therefore the data
structures used to represent information on the disk.
Buffer Manager: Accountable for fetching data from disk storage into main memory,
and deciding what data to cache in main memory.
Data Files: Stores the database itself.

B.Sc II Year IV Sem C.AMBADAS Page 10

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Data Dictionary: Stores metadata (data about data) about the structure of the database,
specifically, the scheme of the database.
Indices: Provides fast access to data items.
Query Processor
The Query Processor contains 3 components:
DDL Interpreter: This interprets the DDL statements and records into the Data
Dictionary.
DML Compiler: It translates the DML statements into query language consisting of low-
level instructions that the query Engine understands.
Query Evaluation Engine: Executes low-level instructions generated by the DML
compiler

Q) Transaction management:
A transaction is a collection of operations that performs a single logical function in
a database applications. In other words, it is a logical unit of work that must be either
entirely completed or aborted.
For example: a transaction that changes the contents of the database must alter the
database from one consistent database state of another.

XYZ=1000/- Consistent state


XYZ=1000-100 Reads, modifies and writes
XYZ=900/- Final consistent state

 Atomicity requires that all operations of a transaction be completed, if not, the


transaction is aborted.
 Consistency means that any database constraints that must be true before the
transaction must also be true after the transaction.
 Isolation means that the data used during the execution of the transaction until
the first one is completed.
 Durability means that the changes are permanent (committed).
 Transaction-management component ensures that the database remains in a
consistent state despite system failures and transaction failures.
 Concurrency is the ability to perform multiple transactions over a shared database
. but, this can create several data integrity and consistency problems,
concurrency-control manager controls the interaction among the concurrent
transactions, to ensure the consistency of database.

Q) Explain data models with an example?

Hierarchical model:- In these model data is organized into a tree like structure. The
structure represents information using parent child relationship each parent can have
B.Sc II Year IV Sem C.AMBADAS Page 11

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


many children but each child has only one parent. The hierarchical model pass
developed in the 1960‟s to manage large amounts of data. In these model it contains
levels or segments. The root segment is the parent of the level one, the level one
segments are parents of level two segments etc.., In these model one to many
relationships between a parent and its children segments.

Network model:- In this network model a parent can have several children and a child
can also have many parent records. Records are physically linked through pointers. This
model was developed in 1960‟s. In this model one to many relationship between the
records. A relationship is called a set. It is composed of parent record and a child record
a set represents a one to many (1:M) relationship between parent and child.

Relational model: The relational data base was introduced in 1970 by E.F codd. In
these model data is maintained in the form of the table consisting of rows & columns
and not through pointers.
Table : EMP
Emp no Emp name Job Salary Dept no
(foreign key)
101 Abc Manager 12000 10
102 Def Clerk 6000 20
103 Ghi Clerk 6500 20
104 Jki Clerk 7000 30
105 Mno Clerk 7500 30
Table: Dept
Deptno D name
(Primay key)
10 Finance
20 Accounts

B.Sc II Year IV Sem C.AMBADAS Page 12

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


30 Marketing

Entity relationship model: ER model is graphical representation of entity, attributes


and relational ships. This model is very popular easy to understand „Peter chen‟ first
introduced the ER data model in 1976.
Entity: An entity can be real world object, either animate (or) inanimate , that can be
easily identifiable .
For example: student, employee, department etc.
Attribute: The properties of an entity is called attributes. All attributes have values.
For example: s.no, name, class, age, marks etc…
Relationship: A relationship is an association among several entity‟s.
For example: An student Enroll the Class.

S no S name marks cid Room

Group
Enroll Class
STUDENT

credits major

Object based data model: object oriented programming has become the software
development methodology this lead to the development of the object oriented data model
that can be seen as extending the ER model with notations of encapsulation methods
and object identity.
OOD model

IN VOICE Belongs to
INVOICE CUSTOMER
Data
member
HAS
Customer
line
LINE

Q)DBMS Architecture
A Database Architecture is a representation of DBMS design. It helps to design,
develop, implement, and maintain the database management system. A DBMS
architecture allows dividing the database system into individual components that can be
independently modified, changed, replaced, and altered. It also helps to understand the
components of a database.
A Database stores critical information and helps access data quickly and securely.
Therefore, selecting the correct Architecture

B.Sc II Year IV Sem C.AMBADAS Page 13

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


o The DBMS design depends upon its architecture. The basic client/server
architecture is used to deal with a large number of PCs, web servers, database
servers and other components that are connected with networks.
o The client/server architecture consists of many PCs and a workstation which are
connected via the network.
o DBMS architecture depends upon how users are connected to the database to get
their request done.

Types of DBMS Architecture

Database architecture can be seen as a single tier or multi-tier. But logically, database
architecture is of two types like: 2-tier architecture and 3-tier architecture.

1-Tier Architecture
o In this architecture, the database is directly available to the user. It means the
user can directly sit on the DBMS and uses it.
o Any changes done here will directly be done on the database itself. It doesn't
provide a handy tool for end users.
o The 1-Tier architecture is used for development of the local application, where
programmers can directly communicate with the database for the quick response.

2-Tier Architecture
o The 2-Tier architecture is same as basic client-server. In the two-tier architecture,
applications on the client end can directly communicate with the database at the
server side. For this interaction, API's like: ODBC, JDBC are used.
o The user interfaces and application programs are run on the client-side.
o The server side is responsible to provide the functionalities like: query processing
and transaction management.
o To communicate with the DBMS, client-side application establishes a connection
with the server side.

B.Sc II Year IV Sem C.AMBADAS Page 14

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

3-Tier Architecture
o The 3-Tier architecture contains another layer between the client and server. In
this architecture, client can't directly communicate with the server.
o The application on the client-end interacts with an application server which
further communicates with the database system.
o End user has no idea about the existence of the database beyond the application
server. The database also has no idea about any other user beyond the
application.
o The 3-Tier architecture is used in case of large web application.

Q) Data base users and administrators


These are classified into two categories, they are
1. Data base users 2. End users
Data base users

Application programmers End users


responsible for developing app.  Sophisticate end users
Program user interface application  Specialized end users
progs will be written as high level  Naïve end users
B.Sc II Year IV Sem C.AMBADAS Page 15

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


language like PASCAL, C & COBOL  Online Users

Sophisticate end users:- sophisticated end users interact with the system without
writing programs. They form requests by writing queries in a database query language.
These are submitted to query processor analysis who submit queries to explore data in
the data base fall in these category.
Specialized end users: - who writes specialized DB applications that do not fit into
fractional DB processing frame work.
Naive end users: - who need not be aware of the presence of the DB systems these are
end users of DB who work through menu driven application.
System analysis: - System analysis determines the requirements of end user and
develop specification for cannel transaction that meets this requirements.
Canned transaction: - Readymade programs through which naïve end users interacts
with the database are called canned transaction.
Online Users: Who may communicate with DB directly through online.
Data base administrator:-
A person in the organization who controls the design and the use of the data base is
called database administrator (DBA). The functions of DBA includes.
Schema definition: - The DBA definition of the logical schema of the data base
according to this schema database will be developed to store required data for an
organization.
Storage structure and access method definition: - The DBA decides how the data is
to be represented in the stored database.
Assisting application programmers: - The DBA provides assistance to application
programmers to develop application programs.
Physical organization modification: - The DBA modifies the physical organization of
the database reflect the changing needs of the organization or to improve performance.
Approving data access:- The DBA determines which user needs access to which part
of the database to which part of the database. According to this, various types of
authorizations are granted to different users.
Monitoring performance:- The DBA monitors performance of the system. The DBA
ensures that better performance is maintained by making changes in physical and
logical schema is required.

Backup and recovery: -


 Database should not be lost or damaged.
 The DBA ensures this periodically backing up the database on magnetic tapes. or
remote services.
 In case of failure, such as virus attack database is recovered from this backup.

Chapter-2

B.Sc II Year IV Sem C.AMBADAS Page 16

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Introduction to Relational Model
Q) Basic structure of relational database:
Components of the relational database theory:
 Entity table
 Attribute (oblique) column(field)
 Domain
 Degree
 Record
 Cardinality
Entity: Things (or) object in a real world with independent existence.
Physical existence: person, car, house, emp etc…
Conceptual existence: job, course, event
(or)
An entity can be object, place, person, event(or) concept in the user environment about
which is organization maintenance the data.

Type Entity
Person EMP, Student
Place Store house
Object Computer, book
Event Sales, admissions
Concept Account, course

Attribute: An attribute is the property of an entity


Example: In EMP entity may have emp no, name, job, salary.
Entity type: It defines a setoff entities that have the same attributes.
Entity set: It is a set of entities of the same type that share the same properties.
Entity instance: It is single occurrence of entity type

Attributes
STUDENT

S.NO STUDENT MARKS


101 Ramya 98 Entity instance
102 Jyothi 97
103 Anil 45
104 Kiran 65

Entity set

Domains of attributes: A set of values that may be assigned to the attributes of each
individual entity is called value set (or) domain.
Ex: domain: color [Red, Blue, White]
Degree: The degree of relation is the number of attributes it contains.
Tuple/records: In relational model terminology all the rows called tuples or records in
the relation.
B.Sc II Year IV Sem C.AMBADAS Page 17

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Cardinality: The no. of tuples it contains if branch relation have5 tuples, the cardinality
of the branch relation is 4.

Q) Database Schema: Schema is the one which defines different database


elements like tables, relationships, views, indexes, packages, procedures,
functions, queues, triggers, and other elements. Schemas are generally stored in a
data dictionary.

o A database schema is the skeleton structure of the database. It represents


the logical view of the entire database.
o A schema contains schema objects like table, foreign key, primary key,
views, columns, data types, stored procedure, etc.
o A database schema can be represented by using the visual diagram. That
diagram shows the database objects and relationship with each other.

o A schema diagram can display only some aspects of a schema like the
name of record type, data type, and constraints. Other aspects can't be
specified through the schema diagram.
Q) Schema Diagrams?

A database schema along with primary key and foreign key dependencies can be
depicted pictorially by schema diagrams. Figure shows the schema diagram for our
banking enterprise. Each relation appears as a box, with the attributes listed inside it
and the relation name above it. If there are primary key attributes, a horizontal line
crosses the box, with the primary key attributes listed above the line. Foreign key
dependencies appear as arrows from the foreign key attributes of the referencing
relation to the primary key of the referenced relation. Many database systems provide
design tools with a graphical user interface for creating schema diagrams.

Q) Explain about different types of keys in DBMS?


A key consist one more attributes that determines other attributes. The different types of
keys are listed below

B.Sc II Year IV Sem C.AMBADAS Page 18

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Super key: It is an attribute that uniquely identifiers a row in a table.


Example: primary key, unique key, alternate key.
Candidate key: A candidate key is a set of one or more fields that can identify a record
uniquely in a table. There can be multiple candidate keys in one table. Each candidate
key can works can primary key.
Example: In the below diagram ID, Roll no, Enroll no are candidate keys, since all
these 3 fields can be work as primary key.
Primary key: It is a setoff one or more fields of a table that uniquely identify a record in
database template it cannot be accept null duplicate values.
Composite key : A key consisting of more than one attribute.
Unique key: Unique key is a set of one or more fields of a table that uniquely identify a
record in database table. It is like primary key but it can accept only once null value and
it cannot have duplicate values.
Secondary key: A non-primary key is known as secondary key. If we don‟t know the
primary key value some other attributes or combination may used for searching.
Foreign key: It is an attribute or combination of attributes in one table which refers to
the value of primary key in another table.
Recursive foreign key: It is an attribute in one table which refers to the values of
primary key in same table.
Alternate Key: Alternate key is a candidate key, currently not selected as primary key of
the table.
Example: License_Number and Passport_Number are alternate keys.

Q) Explain about Relational Query languages?


A query language is a language in which a user requests information from the data base
query language can be categorized into procedural and non-procedural language.
Procedural language: The user instructs the system perform a sequence of operations
on the data base to compute the desired language.
Non procedural language: The user describes the desired information without giving a
specific procedure for obtaining. The information.
B.Sc II Year IV Sem C.AMBADAS Page 19

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


There are a no of “pure query language”
 Relational algebra (procedural)
 Relational calculus (non-procedural)
Q) Relational Operations:
To manipulate relations, relational model supports nine relational algebra operations:
SELECT, PROJECT, JOIN, INSERT, UNION, DIFFERENCE(MINUS), PRODUCT, DIVIDE
and ASSIGNMENT.

1.UNION: Combines all row from two tables, excluding duplicate rows. The tables must
have the same attribute characteristics( the data type should match).

Query: Select sname from T1 Union select sname from T2;


T1 T2 Result
Sname Sname Sname
Ramu Union Kiran Gives Ramu
Raju Ramu Raju
Kiran Srinu Kiran
Srinu

2. Intersect: Yields only rows that appear in both tables. i.e. common rows.
Query: Select sname from T1 Intersect select sname from T2;
T1 T2 Result
Sname Sname Sname
Ramu Intersect Kiran Gives Kiran
Raju Ramu Ramu
Kiran Srinu

3. Differnce: Yields all rows in one table that are not found in the other table.
Query: Select sname from T1 Minus select sname from T2;
T1 T2 Result
Sname Sname Sname
Ramu Difference Kiran Gives Raju
Raju Ramu
Kiran Srinu
4.Product: Yields all possible pairs of rows from two tables - also known as the
Cartesian product. Therefore, if one table has 3 rows and other table has 2 rows, the
product yields a list composed of 3X 2=6 rows
Query: select sname, cname from T1, T2;
T1 T2 Result
Sname Cname Sname Cname
Ramu Product C Gives Ramu C
Raju C++ Ramu C++
Kiran Raju C
Raju C++
Kiran C
Kiran C++

5. Select: also known as RESTRICT, yields values for all the rows or row found in a
table that satisfy given condition. In other words, Select yields a horizontal subset of a
table.

B.Sc II Year IV Sem C.AMBADAS Page 20

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Empno Ename Job
123 Ravi Manager
124 Rajesh Clerk
125 Amar Clerk
126 Kiran Accountant

Select * from emp where job='clerk';

Empno Ename Job


124 Rajesh Clerk
125 Amar Clerk

6. Project: Yields all values for selected attributes. In other words, PROJECT yields a
vertical subset of a table.

Empno Ename Job


123 Ravi Manager
124 Rajesh Clerk
125 Amar Clerk
126 Kiran Accountant

Select Ename, Job from emp;

Ename Job
Ravi Manager
Rajesh Clerk
Amar Clerk
Kiran Accountant

7. Join: Allows information to be combined from two or more tables. JOIN allows the use
of independent tables linked by common attributes. A natural join links tables by
selecting only the rows with common values in their common attributes.

STD Course

Rno Name CID CID Cname


33 Ravi 10 Join 10 C
44 Kiran 30 30 ORACLE
55 Amar 80
Query: select Rno, Name, STD.Cid, Cname from STD, Course where
STD.CID(+)=Course.CID;

Rno Name CID Cname


33 Ravi 10 C
44 Kiran 30 ORACLE
55 Amar 80
Types of joins:

B.Sc II Year IV Sem C.AMBADAS Page 21

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


 Equi join links tables based on an equality condition that compares specified
columns of each table. The outcome of the equijoin does not eliminate duplicate
columns.
 The Join is a non-equi join that compares specified column of each table using
comparison operator other than the 'equals to' operator.
 In an Outer join, the unmatched pairs would be retained and the values for
unmatched other tables would be left blank.

8. Divide: uses one single-column table(A) as the divisor and one 2-column table(B) as
the dividend. The table must be common column.

C1 C2 C1 C2
A 5 Divide A gives 5
A 9 B 9
9. Assignment: Assigns the result set to a variable.
Max_sal:= Select Max(sal) from Emp;

Unit - II
Database Design, ER Model and Relational Database Design
Q) Overview of the Design Process
The task of creating a database application is a complex one, design of the
programs involving design of the database schema, that access and update the
data and design of a security scheme to control access to data. The needs of the
users play a central role in the design process. The design of a complete database
application environment that meets the needs of the enterprise being modeled
requires attention to a broad set of issues. These additional aspects of the expected
use of the database influence a variety of design choices at the physical, logical,
and view levels.

Design Phase: Design phase process is a collection of processes that facilitate the
designing, development, implementation and maintenance of enterprise data
management systems. Properly designed database are easy to maintain, improves
data consistency and are cost effective in terms of disk storage space. The database
designer decides how the data elements correlate and what data must be stored.
The logical model concentrates on the data requirements and the data to be stored
independent of physical considerations. It does not concern itself with how the data
will be stored or where it will be stored physically. The physical data design model
involves translating the logical database design of the database onto physical
media using hardware resources and software systems such as database
management systems.

Design Alternatives: Designing a database schema must ensure that we avoid two
major pitfalls:

B.Sc II Year IV Sem C.AMBADAS Page 22

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Redundancy: The biggest problem with such redundant representation of


information is that the copies of a piece of information can become inconsistent if
the information is updated without taking precautions to update all copies of the
information.

Incompleteness: A bad design may make certain aspects of the enterprise difficult
or impossible to model.

Q) The Entity Relationship Model?


Entity relationship model is graphical representation of entities, attributes and
relationships.
The ER model is based on the following components.
Entity: The entity name is a noun and is generally written in the capital letters. An
entity is represented in the ERD by a rectangle.
An attribute: An attribute describes a property or characteristics of an entity an
attribute is represented by using ellipse.
Relationship- It describes association among the data relationship is represented by a
diamond.

BASIC
SYMBOLS IN
Strong WeakERD Relatio Identifying
Entity Entity nship Relationship

Associative Entity Attribute


Multiv Derived
alued Attribute

Attribut
e

RELATIONSHIPS IN ERD

Unary Binary Ternary

B.Sc II Year IV Sem C.AMBADAS Page 23

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Entity: An entity is a person, place, object, event or concept in the user environment
about which an organization maintain the data.
TYPE ENTITY
Person EMP, STUDENT
Place STORE HOUSE, LAB
Object COMPUTER, BOOK
Event SALES, ADMISSION
Concept ACCOUNT, COURSE

Types of entity‟s:
 Strong entity
 Weak entity
 Associative entity
Strong entity: Strong entity is the one whose existence does not depend on other
entity‟s it is denoted by single rectangle. A strong entity always has the primary key in
the set of attributes that describes the strong entity.
Weak entity:- A weak entity is the one that depends on the other entity. A weak entity is
denoted by the double rectangle. Weak entity‟s do not have the primary keys instead it
has a partial key that uniquely discriminates the weak entity‟s.

Associate entity: These are formed from many to many relationship between entity
types. It is an entity type that associates the instance of one or more entity types and
contains attributes that are peculiar to related entities in the relationship, in the
addition to the attributes referring to the primary keys to related entities.

Attributes: An attribute is a characteristic of entity for example, student entity: name,


roll no, marks, address, there are several types of attributes.
Single value attribute: An attribute that has a single value for a particular entity is
called single valued attribute.
Example: Roll no i.e., every student has only one roll no.

B.Sc II Year IV Sem C.AMBADAS Page 24

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Multi valued attribute: An attribute that may have multiple values for the same
entity is called multi valued attribute. It is represented with Double ellipse symbol
Example: Languages known student menu more than one language.
Composite attribute: Attribute can be sub divided into two or more than one
attribute.
Example: Name attribute can be divided into first name, middle name and last name.
Simple attribute: The attribute which cannot be divided into smaller subparts are
called simple or atomic attributes.
Example: Age.
stored attribute: An attribute which cannot be derived from other attribute is known
as stored attributes.
Example:- Date of birth.
Derived attributes : Attributes derived from the other stored attributes. They are
represented by dotted ellipse symbol.
Example: Average, calculated from the other attributes M1,M2,M3.
Key attribute:- Represents primary key. It is an attribute that has distinct value for
each entity in an entity set. It is represented by Ellipse with Underlining lines represents
key attribute.
Example: Roll no.
Non-key attribute: These are attributes other than primary key(or) candidate key
attributes in the table.
Example: Sname, Fname , address, M1,M2,M3.

What is relationship? Types of relationships?


Relationship means association among entity‟s . Types of relationships.
 1:1 (one two one relationship)
 1:M( one to many relationship)
 Many to many relationship
One to One relationship: In one to one relationship, a single record in table A is
related to only one record in table B and a single record B related to only one record in
table B.

Table A Table B
Person 1 1
Drive Vehicle

B.Sc II Year IV Sem C.AMBADAS Page 25

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


One to many relationship: In one to many relationship, a single record in table A can
be related to one or more records in table B.

1 M Table B
Table A

Ex :-
 An order related to customer .
 A customer can have any orders.
1 M
Customer Order
Place

Many to many relationship: ln a many to many relationship a single record in table A


can be related to one or more records in table B, conversely a single record in the table B
can be related to one or more record in table A.

Table A Table B Table A Table B

Ex:- suppose we are interested in courses and student any student may take several
courses a course may be taken by several student this situation is represent with a
many to many relationship.

M M COURSES
STUDENT

REGISTER
Degree of the relationship :- degree
R of the relationship is the no. of entity types that
participated in the relationship . based on the degree of relationship. They can be
categorized a

1. Unary relationship
2 Binary relationship
3 Ternary relationship
1.Unary relationship: unary relationship is a relationship between the instances of
single entity type . It is also called as recursive relationship here degree of the
relationship is one .

Ex:- “is married to” is unary 1:1 relation ship between instance of the person type i.e.,
one person gets married to another person .

Manages is unary 1:M relationship b/w instance of the employee type i.e., an employee
manages one or more other employees

B.Sc II Year IV Sem C.AMBADAS Page 26

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

2.Binary relationship: binary relationship is a relationship between the instance of


two entity types. Here the degree of the relationship is 2.
Ex: “chairdept” is a binary one to one relationship between instances of the
chairperson and Department . It indicates that one Chairperson has one Department
card.
 “facultyclass” is binary one to many relationship between instances of the faculty
and class types. It indicates one Faculty takes many Class.
 “Enroll” is binary M:M relationship between instances of the student and class
types it indicates student enroll many classes.

One to one
Library card
Employee Has
One to many

Author Write Books


s
Many to many

Student Learns Courses

3.Ternary relationship: Ternary relationship is a simultaneously relationship


among the instances of three entity types it is recommended to convert ternary
relation ship to associative entity‟s. here the degree of the relationship is 3.

B.Sc II Year IV Sem C.AMBADAS Page 27

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Q) Explain about Constraints in ER Model?


An ER enterprise schema may define certain constraints to which the contents of a data
base must confirm.
Mapping cardinalities:- The no of entity‟s to which another entity can be associated via
a relationship. There are most useful is describing binary relationship sets, although
they can contribute to the description of the relationship sets that involve more than the
entity sets.
For a binary relationship set „R‟ between the entity set „A‟ and „B‟. The mapping
cardinality must be one of the following
1. 1:1(one-to-one):- An entity of entity set A can be associated with the almost entity
of entity set B and an entity to entity set B can be associated with almost one entity
of entity set A.

2. 1:M(one-to-many):- An entity set A can be associated with an number of entity‟s


of entity set B and entity in entity set B can be associated with almost one entity‟s of
entity set A.

B.Sc II Year IV Sem C.AMBADAS Page 28

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

3. M:M(many-to-many) :- An entity of entity set A can be associated with an number


of entity‟s of entity set B can be associated with an number of entity‟s of entity set A.

Cardinality constants:- cardinality specifies the min & max no of instances of the entity
that can be associated with each other instances of another entity.
Minimum cardinality:- The min no of instances of one entity that may be associated
with each instances of other entity.
Maximum cardinality:- The max no of instances of one entity that may be associated
with each instances of other entity.
 Where cardinality is indicated in ER diagrams, we can understand the nature of
entity‟s and relationship they share.
 The different symbols are to represent cardinality are shown below.

B.Sc II Year IV Sem C.AMBADAS Page 29

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Ex:-

Participation constraints:-
There are two types of participation constraints
1. Total 2.Partial
The participation of an entity set E in a relationship set R is said to be total in everything
in E participates in at least one relationship R
If only some entity‟s in „E‟ participate in relationship R is said to be partial
Ex:-
Entity R Entity

The double line indicates the total participation. Single line indicates the partial
participation.

Q) Removing Redundant attributes in entity sets?

• Once the entities and their corresponding attributes are chosen, the relationship
sets among the various entities are formed.

• These relationship sets may result in a situation where attributes in the various
entity sets are redundant and need to be removed

• Consider the entity sets instructor and department

– Instructor includes the attributes ID, name, dept_name, and salary with ID
as primary key

– Department includes the attributes dept_name, building, and budget with


dept_name as primary key

• Attribute dept_name appears in both entity sets. It is primary key for entity
department, it is redundant in the entity set instructor and needs to be removed.

B.Sc II Year IV Sem C.AMBADAS Page 30

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


• If both entities have one to one relationship then we can remove it from instructor
table as it will get added up in the relational schema of department.

• But if an instructor has more than one associated department, the relationship
between the entities is recorded in a separate relation inst_dept.

Q) How to Create an Entity Relationship Diagram (ERD)


Now in this ERD Diagram Tutorial, we will learn how to create an ER Diagram. Following
are the steps to create an ER Diagram:

Steps to
Create an ER Diagram
Step 1) Entity Identification
We have three entities

 Student
 Course
 Professor

Step 2) Relationship Identification


We have the following two relationships

 The student is assigned a course


 Professor delivers a course

Step 3) Cardinality Identification


For them problem statement we know that,

 A student can be assigned multiple courses


B.Sc II Year IV Sem C.AMBADAS Page 31

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


 A Professor can deliver only one course

Step 4) Identify Attributes


You need to study the files, forms, reports, data currently maintained by the
organization to identify attributes. You can also conduct interviews with various
stakeholders to identify entities. Initially, it‟s important to identify the attributes without
mapping them to a particular entity.

Once, you have a list of Attributes, you need to map them to the identified entities.
Ensure an attribute is to be paired with exactly one entity. If you think an attribute
should belong to more than one entity, use a modifier to make it unique.

Once the mapping is done, identify the primary Keys. If a unique key is not readily
available, create one.

Entity Primary Key Attribute

Student Student_ID StudentName

Professor Employee_ID ProfessorName

Course Course_ID CourseName

For Course Entity, attributes could be Duration, Credits, Assignments, etc. For the sake
of ease we have considered just one attribute.

Step 5) Create the ERD Diagram


A more modern representation of Entity Relationship Diagram Example

B.Sc II Year IV Sem C.AMBADAS Page 32

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Draw an E-R diagram for the University Enterprise

E-R Diagram for a University Enterprise. Schema Diagram. Relational Schemas.


Classroom (building, room-number, capacity) Department (dept-name, building, budget)
Course (course- id, title, dept-name, credits) Instructor (id, name, depart-name, salary)
Student (ID, Name, Tot- credits) Section (sec-id, semester, year) Time-slot (time-slot-id,
day,start-time, end-time).

This E-R diagram is equivalent to the textual description of the university E-


R model. But with several additional constraints and section now being a weak entity.
University Enterprise, have a constraint that each instructor must have exactly one
associated department.

B.Sc II Year IV Sem C.AMBADAS Page 33

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Q) REDUCTION TO RELATION SCHEMAS:

The database can be represented using the notations, and these notations can be
reduced to a collection of tables.

In the database, every entity set or relationship set can be represented in tabular form.

The ER diagram is given below:

There are some points for converting the ER diagram to the table:

o Entity type becomes a table.

In the given ER diagram, LECTURE, STUDENT, SUBJECT and COURSE forms


individual tables.

o All single-valued attribute becomes a column for the table.

In the STUDENT entity, STUDENT_NAME and STUDENT_ID form the column of


STUDENT table. Similarly, COURSE_NAME and COURSE_ID form the column of
COURSE table and so on.
o A key attribute of the entity type represented by the primary key.
In the given ER diagram, COURSE_ID, STUDENT_ID, SUBJECT_ID, and LECTURE_ID
are the key attribute of the entity.
B.Sc II Year IV Sem C.AMBADAS Page 34

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


o The multivalued attribute is represented by a separate table.
In the student table, a hobby is a multivalued attribute. So it is not possible to represent
multiple values in a single column of STUDENT table. Hence we create a table
STUD_HOBBY with column name STUDENT_ID and HOBBY. Using both the column, we
create a composite key.
o Composite attribute represented by components.
In the given ER diagram, student address is a composite attribute. It contains CITY, PIN,
DOOR#, STREET, and STATE. In the STUDENT table, these attributes can merge as an
individual column.
o Derived attributes are not considered in the table.
In the STUDENT table, Age is the derived attribute. It can be calculated at any point of
time by calculating the difference between current date and Date of Birth.
Using these rules, you can convert the ER diagram to tables and columns and assign the
mapping between the tables. Table structure for the given ER diagram is as below:

Q) What are Entity-Relationship Design Issues

We also understood the various designing shapes that represent a


relationship, an entity and its attributes. However, users often mislead the
concept of the elements and the design process of the ER diagram. Thus, it
leads to a complex structure of the ER diagram and certain issues that does
not meet the characteristics of the real-world enterprise model. The basic
design issues of an ER database schema in the following points:

1. Use of Entity Set vs attributes: The use of an entity set or attribute


depends on the structure of the real-world enterprise that is being modeled
and the semantics associated with its attributes. It leads to a mistake when
the user use the primary key of an entity set as an attribute of another entity
set. Instead, he should use the relationship to do so. Also, the primary key
attributes are implicit in the relationship set, but we designate it in the
relationship sets.
B.Sc II Year IV Sem C.AMBADAS Page 35

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

2. Use of Entity Set vs. Relationship Sets: It is difficult to examine if an


object can be best expressed by an entity set or relationship set. To
understand and determine the right use, the user need to designate a
relationship set for describing an action that occurs in-between the entities. If
there is a requirement of representing the object as a relationship set, then it‟s
better not to mix it with the entity set.

3. Use of Binary vs n-ary Relationship Sets: Generally, the relationships


described in the databases are binary relationships. However, non-binary
relationships can be represented by several binary relationships. For example,
we can create and represent a ternary relationship 'parent' that may relate to
a child, his father, as well as his mother. Such relationship can also be
represented by two binary relationships that is mother and father that may
relate to their child. Thus, it is possible to represent a non-binary relationship
by a set of distinct binary relationships.

4. Placing Relationship Attributes: The cardinality ratios can become an


affective measure in the placement of the relationship attributes. So, it is
better to associate the attributes of one-to-one or one-to-many relationship
sets with any participating entity sets, instead of any relationship set. The
decision of placing the specified attribute as a relationship or entity attribute
should possess the characteristics of the real world enterprise that is being
modeled.
Redundancy of Schemas:
Many to many and one to many relationship sets that are total on the many side can be
represented by adding extra attribute to the many side, containing the primary key of
the "one" side.

Q) Extended entity relationship model(EER) Or Features


EER stands for enhanced entity relationship. Which includes all the concept ER model.
In addition it includes the concepts of sub class and super class and the related
concepts of specialization and generalization.
Super type:- It is the entity type that has got relationship (parent-child relationship)
with one or more subtypes and it contains attributes that are common to its sub types.
Sub type:- sub group of the super type entity and have unique attributes, but they will
be different from each type.
Ex:-

B.Sc II Year IV Sem C.AMBADAS Page 36

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Specialization and generalization:-


Generalization :-
Generalization is an object set that is a super set of another object set.
This is bottom up process of identifying a parent object from child objects.
Generalization is a process of defining more general types from a set of more
specialized.
It form a super type from a set of subtypes.
Ex:- vehicle such as car and truck the ER model of both entity types can create a super
type “vehicle” with the common properties.

Specialization:-
Specialization is an object set that is a subset of another object set. These is a top down
process of deriving child objects from a parent objects
Specialization is a process of defining one or more subparts of the super type.

B.Sc II Year IV Sem C.AMBADAS Page 37

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


It forms subtypes from a super type .
Ex:- An organization needs to store the details of products as a product entity. Some of
the attributes are not necessary when we go for subtypes such as purchased product
and manufacturer product.

Constraints in super type and sub type discriminators:-


There are two types of constraints in super type and sub type:
1.Completeness constraints
2. Disjoint constraints
1. Completeness constraints :- completeness constraint is a type of constraint that
address the question whether an instance of super type must also be a member of at
least one super types or not. There are two rules,
total specialization rule
partial specialization rule

Total specialization :- It specifies that each entity instance of the super type must be a
member of some subtype in the specialization in EER diagram by a double line.
Ex:- A patient must be either be on outpatient or in patient

B.Sc II Year IV Sem C.AMBADAS Page 38

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Partial specialization:- It specifies that the entity instance of super type does not have
to belong any sub type and may or may not be instance of one of the subtypes. Partial
specialization is represented by a single line.
Ex:- If a vehicle is a car it will appear as an instance of CAR. And if truck as an instance
of TRUCK. How ever if the vehicle is a motor cycle it cannot appear as a instance of any
subtype.

2.Disjoint constraints:- Disjoint constraint is a constraint that address the question


whether an instances of a super type may be simultaneously be a member of two or
more sub types. There are two rules
1.Disjoint rule 2. Overlap rule.
1.Disjoint rule:- It specifies that if an entity instance of the super type is a member of
one sub type, it cannot simultaneously be a member of any other sub type. The disjoint
is specified by placing „d‟ in the circle.

2.Overlap rule:- It specifies that simultaneously be a member of two sub types the
overlap is specified by placing an small „o‟ in the circle.
B.Sc II Year IV Sem C.AMBADAS Page 39

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

What are the Alternative Notations for Modeling Data?

Some of the alternative notations used in ER diagrams as follows


1. Many-to-many relationship
A many to many relationship can be represented using crows foot notation as follow

In the above figure X,Y are entity set and R is a Relationship set.
One – to One Relationship
A one – to- one relationship can be alternatively represented as follows,

B.Sc II Year IV Sem C.AMBADAS Page 40

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

5. Generalization can be represented by a triangle and undirected lines as follows

6. Total Generalization
Total Generalization can be represented in a way similar to generalization but with
double line on the top

7. Total partial relationship


A total partial relationship can be represented as follows

Other Aspects of Database Design :

1. Data Constraints and Relational Database Design: Data constraints that


can be expressed using SQL, including primary-key constraints, foreign-key
constraints, check constraints, assertions and triggers. Constraints serve several
purposes in Database.
2. Usage Requirements: Queries, Performance: Database system performance
is a critical aspect of most enterprise information systems. Performance pertains
not only to the efficient use of the computing and storage hardware being used, but
also to the efficiency of people who interact with the system and of processes that
depend upon database data.
There are two main metrics for performance:
Throughput: The number of queries or updates (often referred to as transactions)
that can be processed on average per unit of time.

Response time: The amount of time a single transaction takes from start to finish
in either the average case or the worst case.

3. Authorization Requirements: Authorization constraints affect design of the


database as well because SQL allows access to be granted to users on the basis of

B.Sc II Year IV Sem C.AMBADAS Page 41

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


components of the logical design of the database.
4. Data Flow, Workflow: Database applications are often part of a larger
enterprise application that interacts not only with the database system but also
with various specialized applications.

RELATIONAL DATABASE DESIGN


Q) Explain the features of good relational designs?
 Defining the problem(or) objective.
 Researching the current database.
 Designing the data structure.
 Constructing the data base relationship.
 Implementing rules and constraints.
 Creating the database views and reports.
 Implementing the design of software.
Defining the problem or objective:
Defining the problem the database will address or the objective of the database.
 How the data base will be used?
 What information needs to be store in DB?
 The first step of the database design is to be ask to turn that data into
information.
 The database is designed by collecting all the information that can individual or
organized uses to provide the information to answer some query‟s.
Researching the current data base:

In the most database design, there is sums sort of database already in existence the data
may be stored in different forms like files/folders (or) in excel sheet. The existing data
base information can also provides the nucleus for the constant of new database.

Designing the data structure:

A database is essentially a collection of data tables. The design process in how identify
and describe those each table is a data base once table have been determine and fields
have been assign to each.

Constructing data base relationship:


Establish the relationship between the database by insuring a uniquely that can identify
the individual records in each other.
Implementing rules and constraints:
Define the fields as text or numeric etc … rules and constraints used for data entity.
Creating database views and reports:
The database design is to create the specification that help turn data into useful
information in the form of a report or view of the data.
Implementing the design in software:
In fact the design should only exist as diagram and notes on papers. Here implementing
the database design in software is the finance step.
Q) Atomic domains and First normal form:

A relationship is in first normal form if and only if the domain of each attribute contains
only atomic (individual) value and the value of each attribute contains only a single

B.Sc II Year IV Sem C.AMBADAS Page 42

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


value from that domain. i.e. removing multiple values attributes and preparing atomic
fields.

First normal form: A relation is a first normal formation.


�It is no repeating groups and
�Primary key of the identifiable.
In the given table consist of multiply value attributes(language known) resulting
repeating rules for that column to bring this into INF, we need to remove the repeating
group values.
TABLE WITH ANOMOLIES:-
R.NO SNAME Lang-known Group Fee
101 Ravi Telugu B.SC 6000
Hindi
English
102 Kiran Telugu B.Com 5000
Hindi
103 Arun Telugu B.SC 6000
TABLE IN THE FIRST NORMAL FORM:-
R.no Sname Lang-known Group Fee
101 Ravi Telugu B.SC 6000
101 Ravi Hindi B.SC 6000
101 Ravi English B.SC 6000
102 Kiran Telugu B.COM 5000
102 Kiran Hindi B.COM 5000
103 Arun Telugu B.SC 6000

Q) Decomposition using functional dependencies:


Secondary normal form:- A relation is said to be in second normal for if and only.
�It satisfies first normal form
�It contains no partial dependency
The given table consists of parallel dependencies because sname, group, fee are
department on roll no i.e., part of primary key, to bring this into secondary normal form
we need to remove LANGUAGES known. Attribute and place it in a new table (SAY
LANGUAGES) as shown below and now the table will be in second normal form
language
R.NO LANGUAGES
KNOWN
101 Telugu
101 Hindi
101 English
102 Telugu

B.Sc II Year IV Sem C.AMBADAS Page 43

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


102 Hindi
103 Telugu

STUDENT: TABLE IN 2NF


RNO SNAME Group FEE
101 Ravi B.SC 6000
102 Kiran B. Com 5000
103 Arun B.SC 6000

Third normal form:-


A relation is said to be in 3NF if and only if.
�It satisfies second normal forms
�It contains no transitive dependencies
The given tables consists of transitive dependency because fee is dependent group i.e.,
dependency between two non-key attributes to bring this into 3NF, we need to remove
FEE, Attribute and place it in a new table (say groups) as shown in fig and now the table
will be in 3NF.
STUDENT: TABLE IN 3NF
R.NO SNAME Group
101 Ravi B.SC
102 Kiran B.COM
103 Arun B.SC

LANGUAGES
R.NO LANGUAGES
KNOWN
101 Telugu
101 Hindi
101 English
102 Telugu
102 Hindi
103 Telugu
GROUPS
Group FEE
B.SC 6000
B.COM 5000

Boycott normal form:-


BCNF stands for boycott normal form. This normal form is consider to be special case of
3NF. But there are few differences between BCNF and 3NF.
3Nf satisfies 2NF and has no transitive independences. Transitive dependency exists
only when a key exists only when a non-key attributes determines another non-key

B.Sc II Year IV Sem C.AMBADAS Page 44

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


attribute. But it is possible for non-key attribute to be the determinant of primary key or
part of primary key without violating the 3NF requirements, but it violates BCNF.
“A table is in BCNF if and only if every determinant in the relation is a candidate key”.

�panel 1 exhibits 3NF (button in BCNF) because it satisfies 2NF because it satisfies 2NF
and contains no transitive dependency
�panel 2 exhibits only 2NF because it has partial dependency. Here E determines „B‟
and hence can be a part of primary key
�panel 3 exhibits 3NF and BCNF because it has no transitive dependency and every
determinant is a candidate key.
Ex: The following table a non-key attribute “faculty” determines the part of the primary
key i.e., “subject”. Here the determinant faculty is not a candidate key. Thus it does not
satisfy BCNF.

Section Subject Faculty Time


A Physics Ramesh 7:00
A Computer Arun 8:00
B Physics Ramesh 9:00
B Computer Arun 7:00
C Computer Amar 10:00

The given table is in 3NF and can be converted to a table in BCNF using a simple two
step process.
�The table is modified so that determinant in the table i.e., not a candidate key(faculty)
becomes a component of the primary key of the revised table as:
Section Faculty Subject Time
�decomposing the table eliminate the partial dependency. “subject” is dependent on
“faculty” removing the results the following tables which satisfies the BCNF and 3NF
Sectio Faculty Time
n
A Ramesh 7:00

B.Sc II Year IV Sem C.AMBADAS Page 45

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


A Arun 8:00
B Ramesh 9:00
B Arun 7:00
C Amer 6:00

Facult Subject
y
Rames Physics
h Computer
Arun s
Amer Computer
s

2.Functional dependency theory?


A functional dependency is a relationship
between two attributes. Typically between the primary key and other non-key attribute
within the table. For any relation „R‟. Attributes „Y‟ is functionally dependent attribute „x‟,
x→y
The left hand side of the (FD) is called the determinant and the right hand side is the
dependent the common functional dependency.
→Fully Functional Dependency
→Partial- dependency
→Transitive- dependency
Fully Functional Dependency: All non key attributes are fully dependent on primary
key it is called as fully functional dependency.
Partial dependency:-
A dependency of an attribute an only part of the primary key
Example : 'faculty' partially dependent on 'subject'
Transitive dependency: dependency between two non key attributes.
Attributes example: „Fee‟ is the transitive dependent on the group, which is non primary
key.

Anomalies: Anomaly means „abnormality. Generally a field value changes should be


made in only a single place. But because of data redundancy a field may have different
location there are three types of anomalies found.
1.modification anomalies: If there is some redundant data, when you modify that the
value must be modified in many places. Failure to do so causes modification anomaly,
which result is different for the same attribute.

B.Sc II Year IV Sem C.AMBADAS Page 46

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


2.Insertion anomalies: If there is sum redundant data and when you want to insert
new values for that the values must be inserted in many places. Failure to do so causes
insertion anomaly, which results different sets of records in different table.
3.Deletion anomalies: If there is sum redundant data, when you delete values for that,
the values must to be deletion anomaly which results [having values for the same
attribute.

Decomposition using multivalued dependencies


Fourth normal form(4NF):
A relation „R‟ is in fourth normal form (4NF) if and only if following conditions are
satisfies simultaneously.
�Multi valued dependency (MVD)
�MVD is the dependency where one attribute value is potential a „multivalued fact‟
about another.
Consider the table, suppose employees can be assigned to multilevel projects. Also
suppose the employee can have multiple job skills. Try to normalize the database.
EMP
EMPNO PROJECT NO SKILL
1211 1 ANALYSIS
7 DESIGN
PROGRAM

Solution: In order to normalize it, database with INF as shown below

EMP
EMP NO PROJECT NO SKILL
1211 1 ANALYSIS
1211 1 DESIGN
1211 1 PROGRAM
1211 7 ANALYSIS
1211 7 DESIGN
1211 7 PROGRAM

�This data base shows project no and skill are independent multivalued facts about
employee no i.e., not contains a multivalued independency.
This forms of the table is obviously full of anomalies. There is a high degree of
redundancy that we lead to update problems since the data base contains MVD‟s, so it
should be decompose.
EMP NO�PROJECT NO
EMP NO�SKILL
[Here project and skill are independent to each other so it should be decomposed
according to the 4NF]
EMP_PROJECT(emp no, project no)
EMP_SKILL (emp no, skill)
EMP_PROJECT
EMP NO SKILL
B.Sc II Year IV Sem C.AMBADAS Page 47

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


1211 Analysis
1211 Design
1211 Program
EMP_SKILL
EMP NO PROJECT NO
1211 1
1211 7

Fifth normal form:-


A relation is in fifth normal form(5NF) if and only if it satisfies the following conditions.
 �A relation is already in 4NF.
 It cannot be further non-lasts decompose.
Sales rep Company Product
Ramu Exclusive Books
Ramu Exclusive Magazine
Amar Wordsworth Books
Raju Wordsworth Books
Raju Wordsworth Magazines

If sales representative sells a certain product and they sell it for particular company ,
then they must sell the product for the company
Now, with the extra dependency we could normalize the table into three separate
tables.
Creating a table with sales rep and product.
Sales rep Product
Ramu Books
Ramu Magazines
Amar Books

Creating a table with sales rep and company.


Sales rep Company
Ramu Exclusive
Amar Wordsworth
Ramu Wordsworth

Creating a table with company and product.


Company Product
Exclusive Books
Exclusive Magazines
Wordsworth Books
Wordsworth Magazines

Basically a table is in 5NF if it cannot be made into smaller tables with different keys.

B.Sc II Year IV Sem C.AMBADAS Page 48

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Normal Form:

Normalization is a process of evaluating and correcting the table structures to minimize


data redundancies there by reducing data anomaly normalization works to a series of
stages called normal form like INF,2NF,3NF ETC… If
Involves decomposition of table with anomalies into smaller well structured relations.

First normal form: A relation is a first normal formation.


�It is no repeating groups and
�Primary key of the identifiable.
In the given table consist of multiply value attributes(language known) resulting
repeating rules for that column to bring this into INF, we need to remove the repeating
group values.

TABLE WITH ANOMOLIES:-


R.NO SNAME Lang-known Group Fee
101 Ravi Telugu B.SC 6000
Hindi
English
102 Kiran Telugu B.Com 5000
Hindi
103 Arun Telugu B.SC 6000

TABLE IN THE FIRST NORMAL FORM:-


R.no Sname Lang-known Group Fee
101 Ravi Telugu B.SC 6000
101 Ravi Hindi B.SC 6000
101 Ravi English B.SC 6000
102 Kiran Telugu B.COM 5000
102 Kiran Hindi B.COM 5000
103 Arun Telugu B.SC 6000

Secondary normal form:- A relation is said to be in second normal for if and only.

B.Sc II Year IV Sem C.AMBADAS Page 49

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


�It satisfies first normal form
�It contains no partial dependency
The given table consists of parallel dependencies because sname, group, fee are
department on roll no i.e., part of primary key, to bring this into secondary normal form
we need to remove LANGUAGES known. Attribute and place it in a new table (SAY
LANGUAGES) as shown below and now the table will be in second normal form
language
R.NO LANGUAGES
KNOWN
101 Telugu
101 Hindi
101 English
102 Telugu
102 Hindi
103 Telugu
STUDENT: TABLE IN 2NF
RNO SNAME Group FEE
101 Ravi B.SC 6000
102 Kiran B. Com 5000
103 Arun B.SC 6000

Third normal form:-


A relation is said to be in 3NF if and only if.
�It satisfies second normal forms
�It contains no transitive dependencies
The given tables consists of transitive dependency because fee is dependent group i.e.,
dependency between two non-key attributes to bring this into 3NF, we need to remove
FEE, Attribute and place it in a new table (say groups) as shown in fig and now the table
will be in 3NF.
STUDENT: TABLE IN 3NF
R.NO SNAME Group
101 Ravi B.SC
102 Kiran B.COM
103 Arun B.SC

LANGUAGES
R.NO LANGUAGES
KNOWN
101 Telugu
101 Hindi
101 English
102 Telugu
102 Hindi
103 Telugu
B.Sc II Year IV Sem C.AMBADAS Page 50

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


GROUPS

Group FEE
B.SC 6000
B.COM 5000

Boycott normal form:-


BCNF stands for boycott normal form. This normal form is consider to be special case of
3NF. But there are few differences between BCNF and 3NF.
3Nf satisfies 2NF and has no transitive independences. Transitive dependency exists
only when a key exists only when a non-key attributes determines another non-key
attribute. But it is possible for non-key attribute to be the determinant of primary key or
part of primary key without violating the 3NF requirements, but it violates BCNF.
“A table is in BCNF if and only if every determinant in the relation is a candidate key”.

�panel 1 exhibits 3NF (button in BCNF) because it satisfies 2NF because it satisfies 2NF
and contains no transitive dependency
�panel 2 exhibits only 2NF because it has partial dependency. Here E determines „B‟
and hence can be a part of primary key
�panel 3 exhibits 3NF and BCNF because it has no transitive dependency and every
determinant is a candidate key.
Ex: The following table a non-key attribute “faculty” determines the part of the primary
key i.e., “subject”. Here the determinant faculty is not a candidate key. Thus it does not
satisfy BCNF.

Section Subject Faculty Time


A Physics Ramesh 7:00
A Computer Arun 8:00
B Physics Ramesh 9:00
B Computer Arun 7:00
C Computer Amar 10:00
B.Sc II Year IV Sem C.AMBADAS Page 51

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

The given table is in 3NF and can be converted to a table in BCNF using a simple two
step process.
�The table is modified so that determinant in the table i.e., not a candidate key(faculty)
becomes a component of the primary key of the revised table as:
Section Faculty Subject Time
�decomposing the table eliminate the partial dependency. “subject” is dependent on
“faculty” removing the results the following tables which satisfies the BCNF and 3NF
Sectio Faculty Time
n
A Ramesh 7:00
A Arun 8:00
B Ramesh 9:00
B Arun 7:00
C Amer 6:00

Facult Subject
y
Rames Physics
h Computer
Arun s
Amer Computer
s

Fourth normal form(4NF):


A relation „R‟ is in fourth normal form (4NF) if and only if following conditions are
satisfies simultaneously.
�Multi valued dependency (MVD)
�MVD is the dependency where one attribute value is potential a „multivalued fact‟
about another.
Consider the table, suppose employees can be assigned to multilevel projects. Also
suppose the employee can have multiple job skills. Try to normalize the database.

EMP
EMPNO PROJECT NO SKILL
1211 1 ANALYSIS
7 DESIGN
PROGRAM

Solution: In order to normalize it, database with INF as shown below


EMP
EMP NO PROJECT NO SKILL
1211 1 ANALYSIS
1211 1 DESIGN
1211 1 PROGRAM

B.Sc II Year IV Sem C.AMBADAS Page 52

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


1211 7 ANALYSIS
1211 7 DESIGN
1211 7 PROGRAM

�This data base shows project no and skill are independent multivalued facts about
employee no i.e., not contains a multivalued independency.
This forms of the table is obviously full of anomalies. There is a high degree of
redundancy that we lead to update problems since the data base contains MVD‟s, so it
should be decompose.
EMP NO�PROJECT NO
EMP NO�SKILL
[Here project and skill are independent to each other so it should be decomposed
according to the 4NF]
EMP_PROJECT(emp no, project no)
EMP_SKILL (emp no, skill)
EMP_PROJECT
EMP NO PROJECT NO
1211 1
1211 7

EMP_SKILL

EMP NO SKILL
1211 Analysi
1211 s
1211 Design
Progra
m Fifth normal form:-
A relation is in fifth normal form(5NF) if and only if it satisfies the following conditions.
�A relation is already in 4NF.
�It cannot be further non-lasts decompose.
Sales rep Company Product
Ramu Exclusive Books
Ramu Exclusive Magazine
Amar Wordsworth Books
Raju Wordsworth Books
Raju Wordsworth Magazines

If sales representative sells a certain product and they sell it for particular company ,
then they must sell the product for the company
Now, with the extra dependency we could normalize the table into three separate
tables.

Creating a table with sales rep and product.


Sales rep Product

B.Sc II Year IV Sem C.AMBADAS Page 53

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Ramu Books
Ramu Magazines
Amar Books

Creating a table with sales rep and company.


Sales rep Company
Ramu Exclusive
Amar Wordsworth
Ramu Wordsworth

Creating a table with company and product.


Company Product
Exclusive Books
Exclusive Magazines
Wordsworth Books
Wordsworth Magazines

Basically a table is in 5NF if it cannot be made into smaller tables with different keys.
The database design Methodology for Relational Databases
The methodology is depicted as a bit by bit guide to the three main phases of database
design, namely: conceptual, logical, and physical design.

Conceptual database design - to build the conceptual representation of the


database, which has the identification of the important entities, relationships, and
attributes.

Logical database design - to convert the conceptual representation to the logical


structure of the database, which includes designing the relations.

Physical database design - to decide how the logical structure is to be physically


implemented (as base relations) in the target Database Management System (DBMS).
Conceptual database design steps are:

 Build a conceptual data model


 Recognize entity types
 Recognize the relationship types
 Identify and connect attributes with entity or relationship types
 Determine attribute domains
 Determine candidate, primary, and alternate key attributes
 Check model for redundancy
 Validate the conceptual model against user transactions
 Review the conceptual data model with user

Logical Database design Methodology:

B.Sc II Year IV Sem C.AMBADAS Page 54

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


 Obtain the relations for the logical data model
 Authorize those relations using normalization
 Validate those relations against user transactions
 Check integrity control and its limitation
 Evaluate the logical data model with user
 Combine logical data models into the global model (This step is an optional one)
 Check for future growth and development

Physical Database design Methodology

o Design base relations


o Design representation of derived data
o Design general constraints

 Design file organizations and indexes


o Analyze transactions
o Choose file organizations
o Choose indexes
o Estimate disk space requirements
o Design user views
o Design security mechanisms
o Consider the introduction of controlled redundancy
o Monitor and tune the operational system

B.Sc II Year IV Sem C.AMBADAS Page 55

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Unit -III
Introduction to SQL
Q) Define SQL? Types of SQL Commands?
Ans) SQL Stands for structured query language. SQL used to write queries that store, alter
and retrieve data and meta data of a relational database.
Features of SQL: -
 This is a non- procedural language.
 This is the undefined language i.e., common for many databases.
 This is the fourth-generation language(4GL) in which programmer concentrates on
what rather than the how.

Q) SQL commands can be classified in the three types


1.Data definition language (DDL)
2.Data manipulation language (DML)
3.Data control language (DCL)

Data Definition Language (DDL):-


DDL commands are user to define a database including creating, altering
and dropping tables and establishing constraints deals with metadata. The
commands are CREATE, ALTER, DROP, TRUNCATE, RENAME.

CREATE: To create oracle database objects such as tables, views, indexes,


clusters and synonyms etc.
Alter: To alter the structure of a database object.
Drop: TO delete a database object.
Truncate: To delete rows (not the table‟s structure) with auto commit.
RENAME : To rename a database object

Data manipulation language (DML):-


DML commands are used to maintain and access a database, including
updating, inserting, modifying and querying data. It deals with the data.
The commands are: INSERT, UPDATE and DELETE.

Insert command :To retrieve data from a table and it allows filtering.
Update command: To update the values of attributes.
Delete command: To delete rows from a table

B.Sc II Year IV Sem C.AMBADAS Page 56

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Data Control Language (DCL):-


DCL commands are used to control a database including administrating
privileges and the committing of data. It deals with accessibility and
transaction changes. It includes a set of privileges that can be granted to or
revoked from a user.
The commands are: GRANT, REVOKE, COMMIT, ROLLBACK and
SAVEPOINT.
Grant command:- To give privilege on database objects to other users
Revoke command: - To cancel privileges on database-objects to other users
Commit command: To make changes permanent.
Rollback command: To cancel the changes (i.e., to restore the data)
Save point command To set margin for commit or rollback.

Data Definition Language:


DDL commands are user to define a database including creating, altering
and dropping tables and establishing constraints deals with metadata. The
commands are CREATE, ALTER, DROP, TRUNCATE, RENAME.

1.CREATE command
Purpose: - To create oracle database objects such as tables, views, indexes,
clusters and synonyms etc.

Syntax: -
CREATE TABLE table_name (column_name data0type (size),
[CONTRAINT constraint_name] [constraint_type] …);

Example: - To create a table student with rno, name, marks attributes.


CREATE TABLE STUDENT(RNO NUMBER(2), NAME VARCHAR2(20), MAX
NUMBER(3));

2. Alter command
Purpose:- To alter the structure of a database object.

Syntax: -
ALTER TABLE table_name
[ADD Column_name datatype(size)]
[Modify column_name datatype(size)]
[Drop column column_name];
B.Sc II Year IV Sem C.AMBADAS Page 57

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Example: - To add a new column to an existimg table. The following query


adds a new column to students table.

ALTER TABLE STUDENT AND (AVERAGE NUMBER (5,2));

Example: - To modify the length of an existing column of a table. The


following query modifies the length of the existing attribute rno to „3‟ in
student table.

ALTER TABLE STUDENT MODIFY RNO NUMBER(3);

3. Drop command
Purpose: TO delete a database object

Syntax: -
DROP OBJECT_TYPE OBJECT_NAME;
Example: - The following queries demonstrate deleting a table, an index
and a view respectively.
● DROP TABLE ITEMS;
● DROP INDEX DNAME_IND;
● DROP VIEW EMP_VIEW;

4.Truncate command
Purpose: To delete rows (not the table‟s structure) with auto commit

Syntax: -
TRUNCTATE TABLE tablename;

Example: - To delete complete information from a table.


TRUNCATE TABLE STUDENT;

5.RENAME command

Purpose: - To rename a database object

Syntax: -
RENAME OLD_Table_name to new_tablename;
B.Sc II Year IV Sem C.AMBADAS Page 58

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Example: - The following query renames a table


RENAME STUDENT to STD;

Data Manipulation Language (DML:


DML commands are used to maintain and access a database, including
updating, inserting, modifying and querying data. It deals with the data.
The commands are: INSERT, UPDATE and DELETE.

1.Insert command
Purpose: - To retrieve data from a table and it allows filtering.
Syntax: -
INSERT INTO table_name(column_list) VALUES (value_list);
Example: - To insert only emp number, ename, job and salary. i.e., values
for only few columns (not all)

INSERT INTO EMP (EMPNO, ENAME, JOB, SAL) values (8888, „KIRAN‟,
CLERK,4000);
Example: - To insert a record through parameter substitution.
INSERT INTO EMP VALUES(&EMPNO, „&ENAME‟, „&JOB‟, &SAL);
Enter value for EMPNO:7666
Enter value for ENAME: SHYAM
Enter value for JOB: MANGER
Enter value for SAL: 9500

2.Update command
Purpose: - To update the values of attributes.
Syntax:
UPDATE Table_name SET column_name=value
[Column_name=value……...] [Where condition];
Example: - To set smith‟s salary to 8000
● Update EMP SET SAL= 8000 WHERE ENAME= „SMITH‟;
Example: - To increase the salary of employees by 10%
● UPDATE EMP SET SAL= SAL+SAL*0.1;
Example: - To update values of multiple attributes at a time.
● UPDATE EMP SET SAL=8000, COMM=100 WHERE JOB= „MANAGER‟;
3.Delete command
Purpose: - To delete rows from a table
B.Sc II Year IV Sem C.AMBADAS Page 59

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Syntax: -
DELETE FROM table_name[WHERE_CONDITION];

Example: - to delete the records of clerks.


● DELETE FROM EMP WHERE JOB= „CLERK‟;
Example: - To delete all records of table
● DELETE FROM STD;
(OR)
● DELETE STD;

Data Control Language (DCL):-


DCL commands are used to control a database including administrating
privileges and the committing of data. It deals with accessibility and
transaction changes. It includes a set of privileges that can be granted to or
revoked from a user.
The commands are: GRANT, REVOKE, COMMIT, ROLLBACK and
SAVEPOINT.
Some of the privileges used here are: Select, insert, delete, update, all
references and with grant
1.Grant command
Purpose: - To give privilege on database objects to other users
Syntax: -
GRANT privilege list role on object to user_list public [WITH GRANT
OPTION];
Example: - To grant all permissions on emp table to everybody
● GRANT ALL ON EMP TO PUBLIC;

Example: - To grant select, delete permissions on dept table to Ravi


● GRANT SELCET, INSERT ON DEPT TO RAVI;
Example: - To grant all permissions on „emp‟ table to „KIRAN‟. And „Kiran‟
should be able to give further grants on emp to other users
● GRANT ALL ON EMP TO KIRAN WITYH GRANT OPTION;
2.Revoke command
Purpose: - To cancel privileges on database-objects to other users
Syntax: -
REVOKE PRIVILEGE_LIST ROLE ON OBECT FROM USER
PUBLIC;
Example: - To revoke update privilege from everybody on emp table
B.Sc II Year IV Sem C.AMBADAS Page 60

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


● Revoke update on emp from public;
Example: - To revoke all privileges on emp from Ravi.
● REVOKE ALL ON EMP FROM RAVI;
3.Commit command
Purpose: - To make changes permanent.
Syntax: -
COMMIT;
Example: - To delete records of clerks and save the change on emp table.
● Delete from EMP where JOB= „CLERK‟;
● Commit;
We will not be able to retrieve the records of clerk back.
4.Rollback command
Purpose: -To cancel the changes (i.e., to restore the data)
Syntax: -
ROLLBACK;
Example: - To delete records of clerks and retrieve them back
● Delete from emp where JOB= „CLERK‟
● ROLLBACK;
We will be able to restore the records of clerk back.
5.Save point command
Purpose: - To set margin for commit or rollback.
Syntax: -
SAVE POINT (Save point_name);
Example: -
● Delete from EMP where JOB= „MANAGER‟
● Save point p1;
● Delete from EMP where JOB= „CLERK‟
● Roll back to p1;
● Commit;

Basic Structure of SQL Queries:


Select Command: -
The basic structure of an SQL query consists of three clauses: SELECT,
FROM and WHERE.
SELECT Clause:
The SELECT clause list the attributes desired in the result of a query. SQL allows
duplicates in the relations as well as query results.
FROM Clause:
The FROM clause lists the relations involved in the query.

B.Sc II Year IV Sem C.AMBADAS Page 61

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Where Clause:
The SQL WHERE clause is used to specify a condition while fetching the data from a
single table or by joining with multiple tables.
GROUP BY: This clause which groups rows according to the category specified.
ORDER BY: This sorts the final results rows in ascending (or) descending order.
Purpose: To retrieve data from a table, and it allows filtering.
Syntax:
SELECT[DISTINCT] column_list
FROM Table_List
[WHERE CONDITION]
[GROUP_BY grouping_columns]
[HAVING Group_condition];
Example: - To select complete information from the table student.
● SELECT * FROM EMP;
Example: - To select records of the employees whose salary >=2000, from
emp tables entire rows
● SELECT * FROM EMP WHERE SAL>=2000;
Example: - To select name, job, salary from the emp table(limited columns);
● SELECT ENAME, JOB, SAL FROM EMP;
Example: - To select names of all managers from the emp table (limited
columns and rows)
● SELECT NAME FROM EMP WHERE JOB= „MANGER‟;

Q) Additional Basic operations


An operator is a reserved word (or) a character used primarily in a SQL
statements. In SQL there are many operators be like arthematic operators,
relational operators, logical operators etc… these operators are used in DML
commands like SELECT, INSERT, UPDATE AND DELETE.

 Athematic operators
 Comparison (or) relational operators
 Logical operators

Arithmetic operators:-
+ Addition – adds the values on either side of the operator.
-subtraction -subtracts right hand operand from left hand operand.
* Multiplication – multiplies values on either side of operator.
/ Division – Divides lefthand operand by right hand operand.
Ex:-
Select SAL+500 from emp;
Select SAL-500 from emp;
Select SAL*500 from emp;
B.Sc II Year IV Sem C.AMBADAS Page 62

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Select SAL/2 from emp;
Comparison (or) relational operator:-
‘=‟ checks if the values of the two operands are equal or not, if yes the
condition becomes true
‘!=’ checks if the values of the two operands are equal or not if the values
are not equal then condition becomes true
‘< >’ checks if the values of the two operands are equal or not, if the values
are not equal then condition becomes true.
‘>’checks if the value of the left operand is greater than the value of the
right operand , if the condition becomes true.
‘<’ checks if the value of the left operand is less than the value of right
operand, if yes then the condition becomes true.
‘>=’ checks if the value of the left operand is greater than or equal operand,
if yes then condition becomes true.
‘<=’ checks if the value of the left operand is less than or equal to the value
of right operand, if yes then condition becomes true.
Ex:-
Select * from emp where SAL= 10000;
Select * from emp where SAL != 10000;
Select * from emp where SAL<> 10000;
Select * from emp where SAL> 10000;
Select * from emp where SAL< 10000;
Select * from emp where SAL>= 10000;
Select * from emp where SAL<= 10000;
Logical operators:-
AND – the AND operator allows the existence of multiple condition in SQL
statement where clause.

OR – The OR operator is used to combine multiple conditions in SQL


statements where clause.

NOT – the NOT operator reverses the meaning of logical operator.

Ex:-
select * from emp where NAME= „SMITH‟ AND emp no= 7368;
select* from emp where NAME= „SMITH‟ AND emp no= 7368;
select * from emp where SAL NOT BETWEEN 1500 AND 3000;

Special Operator:-
ALL – The all operator is used to compare a value to all values in another
value list.
Ex:-
Select * from emp where SQL>= ALL (1500,4000);
IN – checks whether a value matches only value in a list.
Query: - To select records of smith, james and allen from emp table.

B.Sc II Year IV Sem C.AMBADAS Page 63

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Select * from emp where ENAME in („james‟, „smith‟, „allen‟);
Between – AND:- checks weather the value is with in the range.
Query: - To select records of employees whose salary is between 2000 and
4000 from emp table.
Select * from emp where sal is BETWEEN 2000 and 4000;
EXISTS: - checks weather a sub query returns a row .
Query: - To select the dept no in which there are no employees.
Select dept no from dept no from dept where NOT EXISTS (select Dept
no from emp where Deptno = Dept Dept no);
LIKE:- Checks weather a value matches a string pattern.
Query:- TO print the employee names whose name start with „R‟.
Select * from emp where ename like „R%‟;
IS NULL:- Check weather a value is NULL.
Query:- To select records of emp whose common is NULL.
Select * from emp where COMM is NULL;
|| (concatenates) – concatenates (appends) two values.
Query:- to concatenate the names „RAVI‟ and „varma‟;
Select „RAVI‟ || „varma‟ from dual;

Q) Set operations in SQL?

SQL supports few set operations which can be performed on the the table data.
1. Union
2.Union All
3.Intersect
4.Minus

1.UNION: Combines all row from two tables, excluding duplicate rows. The tables must
have the same attribute characteristics( the data type should match).

Query: Select sname from T1 Union select sname from T2;


T1 T2 Result
Sname Sname Sname
Ramu Union Kiran Gives Ramu
Raju Ramu Raju
Kiran Srinu Kiran
Srinu

2.UNION ALL: Combines all row from two tables, including duplicate rows.

Query: Select sname from T1 Union ALL select sname from T2;
T1 T2 Result
Sname Sname Sname
Ramu Union ALL Kiran Gives Ramu
Raju Ramu Raju
Kiran Srinu Kiran
B.Sc II Year IV Sem C.AMBADAS Page 64

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Kiran
Ramu
Srinu

3. Intersect: Yields only rows that appear in both tables. i.e. common rows.
Query: Select sname from T1 Intersect select sname from T2;
T1 T2 Result
Sname Sname Sname
Ramu Intersect Kiran Gives Kiran
Raju Ramu Ramu
Kiran Srinu

3. Minus: Yields all rows in one table that are not found in the other table.
Query: Select sname from T1 Minus select sname from T2;
T1 T2 Result
Sname Sname Sname
Ramu Difference Kiran Gives Raju
Raju Ramu
Kiran Srinu

Q)Null values
The SQL NULL is the term used to represent a missing value. A NULL
value in a table is a value in a field that appears to be blank.
A field with a null value is field with no value. It is important to
understand that a null value is different than a zero value or a field that
contains spaces.
Basic structure of NULL by creating a table
Syntax:-
CREATE TABLE LIB_BOOKS (ACC_NO NUMBER(10) NOT NULL, TITLE
VARCHAR2(20), AUTHOR VARCHAR2(20), DEPTNM VARCHAR2(20),
PURDATE DATE, PRICE NUMBER(10,2));
Here NOT NULL signifies that columns always accept on explicit value of the
given datatype. There are some columns where we didn‟t use NOT NULL,
which means these columns could be NULL. A field with a null value is 1
that has been left blank during the record creation.
Lib_Books
Acc_no Title Author Deptnm Purdate Price
100 Oracle db 11 g Navathe Cs 02-jun-2000 290
101 DB concepts Miller Cs 13-dec-2008 540
102 Quantum theory Shaw Phy 16-mar-2010 690
103 Discrete maths Schand Mat 20-oct-2012 450
104 C Programming Balaguru Cs 14-aug-2005
swamy
105 Discreating Kneeth Mat 10-jul-2009
106 Engineering maths Michael Mat 15-feb-2011

B.Sc II Year IV Sem C.AMBADAS Page 65

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Write a query to retrieve records from the library books whose price is
not null
Lib_ books
Acc_ no Title Author Dept nm Pur date Price
100 Oracle db 11g Navathe Cs 02-jun- 290
2000
101 DB concepts Miller Cs 13-dec- 540
2008
102 Quantum Shaw Physics 16-mar- 690
theory 2010
103 Discrete maths Schand Maths 20-oct- 450
2012

Write a query to retrieve records from the library books whose price is NULL
Lib_ books
Acc_ no Title Author Deptnm Purdate Price
104 C programing Balaguru Cs 14-aug-2005
swamy
105 Discreating Kneeth Maths 10-jul-2009
106 Engineering Michael Maths 15-feb-2011
maths

Aggregative functions:-
These functions are used to operate on a group of values. They
aggregate the group perform calculation such as finding out sum, max etc…
These functions can be used with the group by clause to categorize results.
1. SUM( ): Finds average of the values of a column
Ex:- SELECT SUM(SAL) FROM EMP;
2. AVG( ): Finds average of the values of a column.
EX:- SELECT AVG(SAL) FROM EMP;
3. MAX( ): Finds maximum of the values of a column.
EX:- SELECT MAX(SAL) FROM EMP WHERE JOB= ‘MANAGER’;
4. MIN( ): Finds minimum of the values of columns.
EX:- SELECT MIN(SAL) FROM EMP;
5. COUNT( ): Finds number of records.
EX:- SELECT COUNT(*) FROM EMP;
6. STDDEV( ): Finds standard deviation of the values of column.
EX:- SELECT STDDEV(SAL) FROM EMP;
7. VARIANCE( ): Finds variance of the values of a column.
Ex:- SELECT VARIANCE(SAL) FROM EMP;

Aggregation with Grouping

B.Sc II Year IV Sem C.AMBADAS Page 66

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Sometimes we need to perform grouping of the data in cases like finding out
number of employees in each department. The group by statement is
commonly used in conjunction with the aggregate functions to grouping the
records by one or more columns. If we want the sets of grouped data to
satisfy a condition we use „HAVING‟ clause. So usage of group by is
mandatory when using HAVING clause in queries. The syntax of using
GROUP and HAVING is shown below.
SELECT column_ name , aggregate _ function (column_ name)
FROM TABLE_ name
[WHERE column_ name operator value]
GROUP BY column _name
HAVING aggregate _function (column_ name) operator value
Examples on group by:
● If we use select count (*) from emp it gives total number of each
department, we include group by deptno in the query
SELECT DEPTNO, COUNT(*) FROM EMP GROUP_BY DEPTNO;
● To list the total salary, max salary, min salary and the average salary
of employees jobwise.
SELECT JOB, SUM(SAL), MAX(SAL), MIN(SAL), AVG(SAL) FROM EMP
GROUP_BY JOB;
● To list the department number and number of clerks in each
department;
SELECT DEPTNO, COUNT(*) FROM EMP WHERE JOB= „CLERK‟
GROUP_BY DEPTNO;
Examples of HAVING:
● To list the jobs, which are done by min of 2 persons
SELECT JOB FROM EMP GROUP_BY JOB HAVING COUNT(*) >=3;
● To list the department number in which maximum employees work
SELECT DEPTNO FROM EMP GROUP_BY DEPTNO HAVING COUNT(*) =
(SELECT MAX(COUNT(*)) FROM EMP GROUP BY DEPTNO;
Q) Explain sub queries (Or) Nested Queries?
A query within another query is called as sub query. It is also called as
nested query or inner query.
Sometimes, we need to process data based on other processed data. In
such cases sub queries are used.
The characteristics of the sub queries are listed below.
 A sub query is a query(select statement) inside a query.
 A sub query is normally expressed in parenthesis.
The first query in a sql statement is known as outer query.
B.Sc II Year IV Sem C.AMBADAS Page 67

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


 The query inside the sql statement is known as outer query
 The inner query is executed first.
 The output of an inner query is used as input for the outer query.
 The entire sql statement is something referred to as a nested query.
 A sub query may produce one or more records. Comprising one or more
columns.
Types of sub queries:-
Single row query:-
Sub queries that can return only one zero rows to the outer statement
are called single row sub queries.
Single row sub queries are sub queries are used with a comparison operator
in a where or having class
Ex:- Write a query to find the second max. salary of the employees in EMP
table
1. Select max(sal) from emp where sal<(select max(sal) from emp);
2. Select ename from emp where sal: (select max sal) from emp;
Where a query to print the name of employee when draws the max salary.
Multi row query:-
Sub queries that can be written more than one row to the outer
statement are called multi row sub queries. Use multi row operator IN, ANY,
ALL.
Ex:- Write a query to list the emp name, deptno., and salary of the
employees who earned max sal, in each department

Select ename deptno, sal from emp where (Deptno, sal) IN(select Deptno,
max (sal) from emp group by deptno

Q) Modification of the Database?


The SQL Commands [ UPDATE AND DELETE] ARE USED TO MODIFY THE
DATA i.e. already the database. The SQL delete commands uses a where
clause.

Update command
Purpose: - To update the values of attributes.
Syntax:
UPDATE Table_name SET column_name=value
[Column_name=value……...] [Where condition];
Example: - To set smith‟s salary to 8000

B.Sc II Year IV Sem C.AMBADAS Page 68

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


● Update EMP SET SAL= 8000 WHERE ENAME= „SMITH‟;
Example: - To increase the salary of employees by 10%
● UPDATE EMP SET SAL= SAL+SAL*0.1;
Example: - To update values of multiple attributes at a time.
● UPDATE EMP SET SAL=8000, COMM=100 WHERE JOB= „MANAGER‟;
Delete command
Purpose: - To delete rows from a table
Syntax: -
DELETE FROM table_name[WHERE_CONDITION];

Example: - to delete the records of clerks.


● DELETE FROM EMP WHERE JOB= „CLERK‟;
Example: - To delete all records of table
● DELETE FROM STD;
(OR)
● DELETE STD;

Intermediate SQL

Q) Join Expressions (OR)


What is a join? Explain types of joins?

Join:- joins are used to fetch information from multiple tables . join is a relational operation
that course two or more tables with a column to be combined into a single set of records.
The type of joins are:
Equi-join, non Equi-join, natural join, outer join, self join, cartesian (product)join.
Consider the following tables for the demonstration of joins :
Std course
Name CID
Rno

33 Ravi 10

44 Kiran 30

r55 Amar 80

B.Sc II Year IV Sem C.AMBADAS Page 69

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in
CID | www.ios.universityupdates.in
Cname
10
Database Management System C

Types of joins:- 20 Java


1.Equi-join: A join in which the joining condition is
30 oracle
based on equality b/w values in the common columns.
Common columns appear in the table. The following
query displays the values of rno, name, course id and course name form student and course
tables by joining them and gives the output shown.
SELECT RNO, NAME, STD.CID, COURSE.CID, CNAME FROM STD, COURSE
WHERE STD.CID= COURSE.CID;
STD COURSE
R.NO NAME CID CID CNAME
33 Ravi 10 10 C
44 Kiran 30 30 ORACLE

2.Non-Equi-join: A join in which the joining condition is based on Non -equality b/w
values in the common columns.The following query lists the names of the student and
subject not known to them in alphabetical order. The output is also shown below.

SELECT RNO, NAME, CNAME FROM STD, COURSE WHERE STD.CID!=


COURSE.CID ORDER_BY NAME;

R.NO NAME C NAME


55 Amar C
55 Amar Java
55 Amar Oracle
44 Kiran C
44 Kiran Java
33 Ravi Java
33 Ravi Oracle

3.Natural join: same as equi-join except one of the duplicate columns is eliminated in the
result table. The following query list the values of rno, name, course id and course names

B.Sc II Year IV Sem C.AMBADAS Page 70

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


form the student and course tables by joining them .The common column course id is not
duplicated. The output is similar to first one [equi-join] but without a duplicate column for
CID.
SELECT RNO, NAME, STD.CID, CNAME FROM STD, COURSE WHERE STD.CID=
COURSE.CID;

4.Outerjoin:- A join in which rows that do not have matching values in common columns
are also included in the result table. It includes left outer join and right outer join.
● Left outer join:- left outer join gives records form second table even if there are no
matching values in the first table. The following query display all the records of course
table even if there is no matching course id in std table.

SELECT RNO, NAME, STD.CID, CNAME FROM STD, COURSE WHERE STD.CID(+)=
COURSE.CID;

CID CNAME R.NO NAME

10 C 33 Ravi

20 JAVA 44 Kiran

30 ORACLE

● Right outer join:- Right outer join records form table even if there are no
matching values in the second table. The following query display all the records of
student table even if there is no matching course id in course table
SELECT RNO, NAME, STD.CID, CNAME FROM STD, COURSE WHERE STD.CID=
COURSE.CID(+);

R.NO NAME CID CNAME


33 Ravi 10 C
44 Kiran 30 ORACLE
55 Amar 80

B.Sc II Year IV Sem C.AMBADAS Page 71

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


5.Self join(RECURSIVE JOIN):- This is a join in which a table is joined to itself
where joining condition is based on columns of same table. These join is also called as
recursive join
The following query list the names of the employees and their managers from emp table.
SELECT E1.NAME EMPLOYEE, E2.ENAME MANAGER EMP E1,EMP E2 WHERE
E1.MGR=E2 EMPNO;

6.Cartesian product join:- A join in which all possible combinations of all the rows of
first table with each row of the second table appear. The following query displays all the
combination of name of STD table and cnames of course table has 3 records. If STD table
has 3 records and course table has 3 records the result will have a total of 9(the product of
3*3) records.
SELECT NAME, CNAME FROM STD, COURSE;
NAME Cname

Ravi C

Kiran C

Amar C

Ravi Java

Kiran Java

Amar Java

Ravi Oracle

Kiran Oracle

Amar Oracle

Q) What is View? How do you create a view? Drop the View?


View:- view is a virtual table based on one or more tables or views. It can be treated as a
stored query. The table on the which a view is based is called base table. There are
limitations on updating data through a view. If views can be updated, those changes can be
transferred to the underlying base tables. The advantages and disadvantages are discussed
below.
Advantages:-
● Simplify query commands (e.g., if view is based on a query that join three tables we
not write the query again and again).
● Provide date security and confidentially.
B.Sc II Year IV Sem C.AMBADAS Page 72

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


● Contain most current base table data.
● View use little storage space.
Disadvantages:-
● Use processing time re-creating view each time it is referenced.
● May or may not be directly updateable.
● Cannot be indexed.
Syntax :- CREATE VIEW view_name AS SELECT column_name (s) from table_name
WHERE condition;

EX:-

● The following query creates a view of managers of EMP table.


● Create VIEW MANAGERS AS SELECT * FROM EMP WHERE JOB=
‘MANAGER’;
● To select records from the view that has been created, we use the following
SELECT * FROM MANAGERS;
● The following query provides view of the name, job, salary and department name, this
view is based on multiple table i.e., it has two base table EMP and DEPT.

CREATE VIEW EMPDEPTVIEW AS


SELECT ENAME, JOB, SAL, DNAME FROM EMP, DEPT
WHERE EMP.DEPTNO=DEPT.DEPTNO AND JOB =‘MANAGER’;

SQL DROPPING A VIEW:


You can delete a view with the DROP VIEW command
Syntax: DROP VIEW view-name
Example: DROP VIEW empview;

Q) What is Transaction?
A transaction is a set of SQL statement which oracle treat as a single unit.ie., all the
statement should execute successfully or none of the statements should execute.
To control transactions oracle doesn’t made permanent any DML statement unless
you commit it. If you don’t commit the transaction and power goes off or system crashes
then the transaction is roll backed.
Transaction control statement manages changes made by DML. Statement TCL
statement available in oracle one.
COMMIT: make changes done in transaction permanent.
ROLLBACK: Roll back the state of database to the last commit point.
SAVE POINT: Use to specify a point in transaction to which later you can
rollback.

B.Sc II Year IV Sem C.AMBADAS Page 73

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


COMMIT: To make the changes done in a transaction permanent issue the COMMIT
statement.
Syntax:
COMMIT;
Example:
Insert into emp(empno,ename,sal) values(101,’asdf’,9000);
Commit;
Rollback: To rollback the changes done in a transaction give rollback statement. Rollback
restore the state of the database to the last commit point.
Example:
Delete from emp;
Rollback; /* undo the changes */

Savepoint:
Specify a point a transaction to which later you can rollback.
Example:
Insert into emp (empno,ename,sal) values(101,’aaaa’,9000);
Savepoint A;
Insert into dept (deptno,dname) values(10,’bbbb’);
Savepoint B;
Insert into salgrade (empno,sal) values(103,7000);

Now if you give


Rollback to A;
Then row from salgrade table and dept will be roll backed. At this point you can commit the
row inserted into emp table or rollback the transaction.

If you give
Rollback to B;
Then row inserted into salgrade table will be roll backed. At this point you can commit the
row inserted into dept table and emp table or rollback to savepoint A or completely roll
backed the transaction.

If you give
Rollback;
Then the whole transactions is rollbacked.

Q) SQL constraint (integrity constraints)


Constraints: - A constraint is a rule that restricts the values that may
be present in the database constraints case used to ensure proper data
B.Sc II Year IV Sem C.AMBADAS Page 74

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


entity in tables. They should be written when creating the table (or) altering
the table structures. The constraints used in SQL are listed below.

Not null Enforces the values of a column to be not full


i.e., it has a value.
Unique Enforces the values of a column to be unique
i.e., the column does not have the duplicate
values but it allocates null value,
Primary Enforces the values of a column to be unique
key and to be null i.e., the column does not have
duplicate values and null values
Default Provider a default value for a column when
value is not supplied for that
Check Used for checking the values of column against
the condition specified
Foreign key Allow only the values of matching to the values
of another primary key column of another table
or the same table.

Not null: - this constraints ensures all rows in the table contain a define
value for column which specified as not null which means a null value is
not allowed.
Syntax:-
[CONSTRAINT constraint name] NOT NULL
EX:- To create library books table with not null values, the query would be
like.
SQL>create table library_books(access_no(10), not null, title varchar2
(20),author varchar2 (20), pur_date, price number(7,2));

Primary key: - the values of column to be unique and to be not null.


Syntax: -
Column name data type [constraint constraint_name] primary key
Ex:- primary key defined as column levels to create library- books table with
p. k constraints, the query would be like.
Method1:-
SQL>create table library- books(access_no number (10) primary key,
title varchar2 (20), pur-date date, price number(7,2));
Method-2:-

B.Sc II Year IV Sem C.AMBADAS Page 75

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


SQL>Create table library_books (access_no number(10), title varchar2
(20), author varchar2 (20), dept varchar2 (20), pur date date price number
(7,2) primary key (access_no));

Unique:- The columns does not have the duplicate values but it allows the
null value .
Ex:- To create library- books table with unique key, the query would be like:
SQL>create table library_books (access_no number(10). Unique title
varchar2(20). Author varchar 2(20) pur date date, price number (7,2));

Check Constraints:- This constraint defines a business rule on a column


all rows must satisfy this rule. The constraint can be applied, for a single
column (or) a group of columns .
Syntax:-
[constraints constraints_name] check (condition)
Ex:- In the library – books table to select the department, the query would
be like.

SQL>create table library- books (access_no number(10) primary key , title


varchar2(20), deptnm varchar2(20), check(„cs‟, „maths‟, „physics‟), putr-date
date,price num(7,2));

Foreign key (or) referential integrity:- This constraint identifiers any


column referencing the primary key in another table. It establishes a
relationship between two columns in the same table(or) between the
different tables.
Syntax:-
[constraint constraint_name]. references reference_table_name(column name);
Ex:- Let us table are library – books& issued books.
SQL>create table library-books (access_no number(10) primary key, title
varchar2(20), deptnm varchar2(20), pur_date date price number(7,2));

SQL>Create table Issued_books(access_no number (10) references library-


books( access_no), barrower varchar2(20);

Q) What are common SQL data types and schemas?

B.Sc II Year IV Sem C.AMBADAS Page 76

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Data type: - Data type tells what type of value on attribute (or) variable
can hold specifying the datatype for attributes in a table and variables in
program is mandatory.

Char(size) Fixed length character data size characters long.


Max-size= 255; default= 1byte. Padded on right
with blanks to full length of size.
Varchar 2(size) Variable length character string. Max-size up to
2000 bytes
Long Character data of variable size upto 2GB in
length. Only one column may not be used in
subqueries, functions, expressions, where clauses
or indexes. A table containing long data may not
be clustered.
Long varchar Same as long.
Long raw Raw binary data; otherwise same as long (used
for images)
Boolean Stores true or false values.
Number For number column with space for 40 digits plus
space for a decimal ppoint and sign number may
be expressed in two ways; first with numbers 0
to 9, the sign+ and – and decimal point (.); second
in scientific notation.
Ex:- 1.85e3 for. Valid values are 0 and (+) and (-)
numbers from 1.0e-130 to 9.99 e125
Number(size) For number column specified size in digits.
Number (sized) For number column specified “size” with d digits
after the decimal point.
Ex:- Number (5,2) could contain nothing longer
than 999.99 without an error being generated.
Number (*) Same as number.
Small int Same as number (no
decimal)precision 5
Integer Same as number (no decimal) precision 10.
Big int Same as number (no decimal) precision n.
Decimal(p,s) Exact numerical precession p, scales
Ex:- decimal (5,2) is number that has 3 digits
before the decimal and 2 digits after the decimal
same as number.
Float Same as number.
Long varchar Same as long
Row(size) Row binary data, size bytes long, max size=255
bytes

B.Sc II Year IV Sem C.AMBADAS Page 77

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Date Valid dates, range from Jan 1-4712BC to Dec 31-
4712AD. Date in form of dd-mon-yy
Large Binary large objects, character
Objects (BLOB, Large object (up to 4GB)
CLOB)
Q) Authorization?
We may assign a user several forms of authorization on the parts of the database.
Authorizations on data include:-
o Authorization to read data
o Authorization to insert new data
o Authorization to update Data
o Authorization to delete data
Each of these types of authorizations is called a privilege. When a user submits a query or
an update , first checks if the query or update is authorized. If the query or update is not
authorized, it is rejected.
A user Authorization may be allowed to pass on grant. Authorization to other users, to
withdraw(revoke) an authorization was granted earlier.
GRANT:- use to grant privileges to other users or roles.
REVOKE:- Use to take back privileges granted to other users and roles.
1.Grant command
Purpose: - To give privilege on database objects to other users
Syntax: -
GRANT privilege list role on object to user_list public [WITH GRANT
OPTION];
Example: - To grant all permissions on emp table to everybody
● GRANT ALL ON EMP TO PUBLIC;
Example: - To grant select, delete permissions on dept table to Ravi
● GRANT SELCET, DELETE ON DEPT TO RAVI;
Example: - To grant all permissions on „emp‟ table to „KIRAN‟. And „Kiran‟
should be able to give further grants on emp to other users
● GRANT ALL ON EMP TO KIRAN WITH GRANT OPTION;
2.Revoke command
Purpose: - To cancel privileges on database-objects to other users
Syntax: -
REVOKE PRIVILEGE_LIST ROLE ON OBECT FROM USER
PUBLIC;
Example: - To revoke update privilege from everybody on emp table
● Revoke update on emp from public;
Example: - To revoke all privileges on emp from Ravi.

B.Sc II Year IV Sem C.AMBADAS Page 78

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


● REVOKE ALL ON EMP FROM RAVI;
Advanced SQL
What is PL\SQL?
● PL\SQL stands for procedural language extension of SQL
● PL\SQL is a combination of SQL along with the procedural features of
programming languages.
● It was developed by Oracle Corporation in the early 90‟s to enhance
the capabilities of SQL.
A simple PL\SQL block:
Each PL\SQL program consists of PL\SQL statements which from a
PL\SQL block.
DECLARE
Variable declaration
BEGIN
Program execution
EXCEPTION
Exception handling
END;
Declaration section:-
The declaration section of a PL\SQL block starts with the reserved
keyword DECLARE. This section is optional and is used to declare any place
holders like variables, constants, records and cursors.
Execution section:-
The execution section of a PL\SQL block starts with the reserved
keyword begin and ends with END. This is a mandatory section and is the
section where the program logic is written to perform any task.
Exception section:-
The exception section of PL\SQL block starts with the reserved
keyword EXCEPTION. This section is optional. Any occurs in the program
can be handle in this section.
Example:-
DECLARE
x number:=&x;
y number:=&y;
BEGIN
DBMS_OUTPUT.PUT_LINE („sum=‟||(x+y);
END;
The above program gives the following output:
Enter value for x: 50
B.Sc II Year IV Sem C.AMBADAS Page 79

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Enter value for y : 60
Sum=110
Assignments in PL/SQL
Variables can be assigned in two ways:
Using the normal assignment statement (: =)
or as the result of an SQL SELECT or FETCH statement.
For example:
Vempno : =1001;
Vename : = ‟SMITH‟ ;
assignment uses the SET keyword at the start of the line with the “=”
symbol, instead of the “:=”.
For example: SET Vempno = 1001;
Conditional statements in PL\SQL:-
IF-THEN statement:-
The simplest form of IF statement associates a condition with a sequence enclosed
by the keywords THEN and ENDIF (not ENDIF), as follows:
IF condition THEN
Sequences_of_statements
End if;
Example:
DECLARE
a number(3) := 5;
BEGIN
IF( a < 20 ) THEN
dbms_output.put_line('a is less than 20 ' );
END IF;
END;

The sequence of statements is executed only if the condition is true. If the condition is
false or null, the if statement does nothing.

IF-THEN-ELSE statement:-
The second form of IF statement adds the keyword ELSE followed by
an alternative sequence of statements as follows:
IF condition THEN
Sequences_of_statements1
ELSE
Sequence_of_statements2
END IF;
The sequence of statements in the ELSE clause is executed only if the
condition is false or null. Thus the ELSE clause ensures that a sequence of
statements is executed.
B.Sc II Year IV Sem C.AMBADAS Page 80

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Example:
DECLARE
a number(3) := 500;
BEGIN
IF( a < 20 ) THEN
dbms_output.put_line('a is less than 20 ' );
ELSE
dbms_output.put_line('a is not less than 20 ' );
END IF;
dbms_output.put_line('value of a is : ' || a);
END;
Output:
A is not less than 20
Value of a is: 500

If-then-elsif statement:-
Sometimes you want to select an action from several mutually
exclusive alternatives. The third form of IF statement uses the keyword
ELSIF(not ELSEIF) to introduce additional conditions, as follows:
IF condition1 THEN
Sequence_of_statements1
ELSIF condition2 THEN
Sequence_of_statements2
ELSE
Sequence_of_statement3
END IF;
If the first condition is false or null, the ELSIF clause tests another
condition. An IF statement can have any number of ELSIF clauses; the final
ELSE clause is optional. Conditions are evaluated one by one from top to
bottom. If any condition is true, its associated sequence of statements is
executed and control passes to the next statement. If all conditions are false
or null, the sequence in the ELSE clause is executed.

CASE STATEMENT: The CASE statement works like the IF statement, only using the
keyword WHEN. A CASE statement is evaluated from top to bottom. If it get the
condition TRUE, then the corresponding THEN clause is executed and the execution
goes to the END CASE clause.
Syntax:
CASE [ expression ]
WHEN condition_1 THEN result_1
WHEN condition_2 THEN result_2
...
B.Sc II Year IV Sem C.AMBADAS Page 81

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


WHEN condition_n THEN result_n
ELSE result
END
Example:
DECLARE
grade char(1) := 'A';
BEGIN
CASE grade
when 'A' then dbms_output.put_line('Excellent');
when 'B' then dbms_output.put_line('Very good');
when 'C' then dbms_output.put_line('Good');
when 'D' then dbms_output.put_line('Average');
when 'F' then dbms_output.put_line('Passed with Grace');
else dbms_output.put_line('Failed');
END CASE;
END;

Iterative statements in PL\SQL:-


There are three types of loops in PL\SQL:-
● Simple loop
● While loop
● For loop
Simple loop:-
PL/SQL Simple OR exit loop is used when a set of statements is to be executed at
least once before the termination of the loop. There must be an EXIT condition
specified in the loop, otherwise the loop will get into an infinite number of iterations.
After the occurrence of EXIT condition, the process exits the loop.
General syntax to write a simple loop is:-
LOOP
Statements;
EXIT;
{or exit when condition;}
END LOOP;
Example:
DECLARE
i NUMBER := 1;

B.Sc II Year IV Sem C.AMBADAS Page 82

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


BEGIN
LOOP
EXIT WHEN i>10;
DBMS_OUTPUT.PUT_LINE(i);
i := i+1;
END LOOP;
END;

While loop:-
A WHILE LOOP is used when a set of statements has to be executed as long as a
condition is true. The condition is evaluated at the beginning of each iteration. The
iteration continues until the condition become false.
The general syntax to write a WHILE LOOP is:-
WHILE<condition>
LOOP statements;
END LOOP;
Example:
DECLARE
i INTEGER := 1;
BEGIN
WHILE i <= 10 LOOP
DBMS_OUTPUT.PUT_LINE(i);
i := i+1;
END LOOP;
END;

FOR LOOP:-
A FOR LOOP is used to execute a set of statements for a predetermined number of times.
Iteration occurs between the start and end integer values given. The counter is always
incremented by 1. The loop exits when the counter reaches the value of the end integer.
The general syntax to write a FOR LOOP is:-
FOR counter IN initial_value .. final_value LOOP
LOOP statements;
END LOOP;
Example:
BEGIN
FOR k IN 1..10 LOOP
DBMS_OUTPUT.PUT_LINE(k);

B.Sc II Year IV Sem C.AMBADAS Page 83

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


END LOOP;
END;

3. Jumping Control Structures: Jumping Control Structures are used to move control
to other portions in a program or to quit loops.
a) Goto: This moves the control to a specified label.
b) Exit: It stops the execution of a corresponding loop.
c) Exit when: It stops the execution of a corresponding loop on meeting the given
condition.

Example: A program to print first n numbers. This uses „simple loop‟ and „exit- when‟
DECLARE
N NUMBER:=&N;
I NUMBER:=0;
BEGIN
LOOP
I:=I+1;
DBMS_OUTPUT.PUT_LINE(I);
EXIT WHEN I=N;
END LOOP;
END;
What is Exception Handling? Give Example?
Exception Handling: Handling run time errors is exception handling. Actually, when
run-time error occurs, a program gets terminated abruptly. But, exception handling
ensures safe termination of a program. A program can handle multiple exceptions.
Exceptions are two types:
1. System-defined exceptions: These are raised automatically by oracle when a
corresponding runtime error occurs
2. User-defined exceptions: These should be defined and raised by users.
Following table lists System- Meaning
Defined Exceptions. System-
Defined EXCEPTIONS

ZERO_DIVIDE When trying to divide a number by zero

VALUE_ERROR When converting inappropriate


character to a number

INVALID_NUMBER When converting or rounding values

NO_DATA_FOUND When data is not found during fetching

B.Sc II Year IV Sem C.AMBADAS Page 84

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


TOO_MANY_ROWS When more than one row is fetched

DUP_VAL_ON_INDEX When entering duplicate values for a


unique or primary key attribute

LOGIN_DENIED When the login or password are invalid


while log-in

STORAGE_ERROR When it runs out of memory

PROGRAM_ERROR Internal error of PL/SQL

INVALID_CURSOR Illegal cursor opening

CURSOR_ALREADY_OPEN Opening a cursor which is already


opened

OTHERS Can catch any type of exception

The Syntax for ‘Exception Handling’:


DECLARE Declaration section
BEGIN statements
EXCEPTION WHEN ex_name1 THEN
-Error handling statements
WHEN ex_name2 THEN
-Error handling statements
WHEN Others THEN
-Error handling statements
END;
Example: Following program demonstrates handling NO_DATA_FOUND exceptions
DECLARE
N EMP.ENAME%TYPE;
BEGIN
SELECT ENAME INTO N FROM EMP WHERE EMPNO=8888;
EXCEPTION WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('SORRY NO RECORD');
END;

Q) What are Cursors? What are the Types of Cursors? How do you
Create and Access a Cursor? Explain with examples?
Cursor: Cursor is a mechanism that deals with multiple records of a result set fetched
by a SELECT query. It is a temporary work area created in the system memory when a
SQL statement is executed. It iterates multiple records sequentially one by one.
Types of cursors:
1. Explicit cursor: Explicit cursor is declared by the programmer to keep track of a
result set. This must be created in a PL/SQL program explicitly. It has to be opened to
fetch the records. It is applicable only for SELECT command.
2. Implicit cursor: Implicit cursor is defined by PL/SQL and keeps track of information
of rows affected by INSERT, UPDATE, DELETE and SELECT INTO commands. This is
created by oracle automatically when the commands specified are executed. The name of
the implicit cursor is „SQL‟

B.Sc II Year IV Sem C.AMBADAS Page 85

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Steps (Syntax) to use explicit cursor: Opening, closing of cursor and fetching values
from cursor should be written clearly.
DECLARE
CURSOR cursor_name IS query;
BEGIN
OPEN cursor_name;
FETCH cursor_name INTO variables; /* repeated in a loop */
CLOSE cursor_name;
END;
Using FOR loop to work with cursors: here opening, fetching and closing cursor is
done automatically
FOR record_variable IN cursor_name LOOP
Statements;
END LOOP;
Example on Explicit Cursor: Following is a program that prints the names of all the
clerks from “emp” table using cursors.
DECLARE
N EMP.ENAME%TYPE;
CURSOR C1 IS SELECT ENAME FROM EMP WHERE JOB=‟CLERK‟;
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO N;
EXIT WHEN C1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE (N);
END LOOP;
CLOSE C1;
END;
Example on Implicit Cursor:: Following program updates salary of all the managers by
10% and prints number of records that have been updated.
BEGIN
UPDATE EMP SET SAL=SAL+SAL*0.1 WHERE JOB='MANAGER';
IF SQL%FOUND THEN
DBMS_OUTPUT.PUT_LINE (SQL%ROWCOUNT || ' RECORDS UPDATED');
END IF;
END;

Explain Cursor Processing Commands?


Cursor: Cursor is a mechanism that deals with multiple records of a result set fetched
by a SELECT query. It is a temporary work area created in the system memory when a
SQL statement is executed. It iterates multiple records sequentially one by one.
Cursor processing Commands: To work with cursors, we need to use the three cursor
processing commands „OPEN‟, „FETCH‟ and „CLOSE‟.
OPEN: When we open a cursor, it executes the SQL command and populates the cursor
with data. Opening is mandatory to fetch values from the cursor. The syntax to open
cursor is: OPEN cursor_name
FETCH: Fetch is used to retrieve values from that cursor. But, it can fetch values one by
one sequentially until there are no elements found in the cursor i.e. first time it points to
first record, then second record and so on. The syntax to fetch values from a cursor is:
FETCH cursor_name into variable1,variable2,..
CLOSE: This closes the cursor for process. Once, the cursor has been closed we cannot
fetch values from it. The syntax to close a cursor is: CLOSE cursor_name

B.Sc II Year IV Sem C.AMBADAS Page 86

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Explain Cursor Attributes?


Cursor attributes are used to know the state, or current record-
number it is pointing to. There are manly four cursor attributes which
are discussed below. CURSOR ATTRIBUTES

Explicit Cursor Attributes

%found Yields TRUE, if a cursor can fetch


records; FALSE otherwise.

%notfound Yields TRUE, if a cursor cannot fetch


records; FALSE otherwise.

%rowcount Holds the record number it is


pointing to.

%isopen Yields TRUE, if the cursor is in open


state; FALSE otherwise

Implicit Cursor Attributes


SQL%found If no records are affected, it returns
FALSE
SQL%notfound If no records are affected, it returns
TRUE
SQL%rowcount Holds number of rows affected by the
related commands.
SQL%isopen After executing related commands, it
returns FALSE

Q) What are Stored Procedures? Explain.


Stored procedure: It is a named PL/SQL block which performs one or more specific
task. A procedure has a header and a body. The header consists of the name of the
procedure and the parameters. The body consists or declaration section, execution
section and exception section similar to a general PL/SQL Block. It is also a database
object stored in data-dictionary. A procedure can be called in any program.
A procedure takes three types of parameters: IN, OUT, and IN OUT.
• We can only read values form IN parameter
• We can write values into OUT parameter
• We can read and write values, if the parameter is of type IN OUT

Syntax of a Procedure:
CREATE [OR REPLACE] PROCEDURE pocdeure_name [(list of arguments)] IS/AS
Declarations
BEGIN
Statements
END:
Executing a Procedure: A procedure can be executed in two different ways.
• At SQL prompt using the syntax: EXEC proc_name;
B.Sc II Year IV Sem C.AMBADAS Page 87

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


• By calling in a PL/SQL program: proc_name;

Example: Following is a procedure that finds out whether the supplied parameter is
even or odd.
CREATE OR REPLACE PROCEDURE ISEVEN(X NUMBER) IS
BEGIN
IF MOD(X,2)=0 THEN
DBMS_OUTPUT.PUT_LINE('EVEN NUMBER');
ELSE
DBMS_OUTPUT.PUT_LINE('ODD NUMBER');
END IF;
END;
Two different ways of executing the procedure are shown below.
 SQL> EXEC ISEVEN(2);
 BEGIN
ISEVEN(3);
END;

Q) What are Stored Functions? Explain?

A function is a named PL/SQL Block which is similar to a procedure. The major


difference between a procedure and a function is, a function returns a value but a
procedure does not.
Syntax of a Function:
CREATE [OR REPLACE] FUNCTION
Function_name [(list of arguments)] RETURN data_type IS/AS
Declarations
BEGIN
Statements
RETURN value;
END:
Executing a Function: To execute a function, we simply make a call of it in a PL/SQL,
it can also be executed using „EXEC with DBMS_OUTPUT.PUT_LINE statement‟ or by
calling in SELECT statements.
Example: Following is a function that returns factorial of a given
CREATE OR REPLACE FUNCTION FACT(X NUMBER) RETURN NUMBER AS
K NUMBER:=1;
BEGIN
FOR I IN 1 .. X LOOP
K:=K*I;
END LOOP;
RETURN K;
END;
Three different ways of executing the function are shown below.
 � SQL> EXEC DBMS_OUTPUT.PUT_LINE(FACT(4));
 � BEGIN

DBMS_OUTPUT.PUT_LINE('FACTORIAL = ' || FACT(4));


END;
 SQL> SELECT FACT(4) FROM DUAL;

Explain Recursion with examples?


B.Sc II Year IV Sem C.AMBADAS Page 88

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


We have seen that a program or subprogram may call another subprogram. When a
subprogram calls itself, it is referred to as a recursive call and the process is known
as recursion.
To illustrate the concept, let us calculate the factorial of a number. Factorial of a
number n is defined as −

n! = n*(n-1)!
= n*(n-1)*(n-2)!
...
= n*(n-1)*(n-2)*(n-3)... 1
The following program calculates the factorial of a given number by calling itself
recursively −

DECLARE

num number;

factorial number;

FUNCTION fact(x number)

RETURN number

IS

f number;

BEGIN

IF x=0 THEN

f := 1;

ELSE

f := x * fact(x-1);

END IF;

RETURN f;

END;

BEGIN

num:= 6;

factorial := fact(num);

dbms_output.put_line(' Factorial '|| num || ' is ' || factorial);

END;

B.Sc II Year IV Sem C.AMBADAS Page 89

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


/

When the above code is executed at the SQL prompt, it produces the following result −

Factorial 6 is 720

PL/SQL procedure successfully completed.

B.Sc II Year IV Sem C.AMBADAS Page 90

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


UNIT - IV
Transaction Management

Q) What is a Transaction? What are its Properties?

Transaction: A Transaction is any action that reads from and/or writes to a database. It
is a logical unit of work that must be either entirely completed or aborted. Most real-
world database transactions are formed by two or more database requests. A database
request is the equivalent of a single SQL statement in an application program. A
Transaction can be:
 Simple SELECT statement to list table contents
 A series of related UPDATE statements to change the values of attributes.
 A series of INSERT statements to add rows to one or more tables
 A combination of SELECT, UPDATE, and INSERT statements

Example: Following is an example of a transaction. A transaction that changes the


contents of the database must alter the database from one consistent database state to
another. And, every transaction must begin with the database in a known consistent
state.
Properties of Transactions: Each transaction must display ACID properties: Atomicity,
Consistency, Isolation and Durability.

 Atomicity: Atomicity requires that all operations of a transaction be completed; if


not, the transaction is aborted. There must be no state in a database where a
transaction is left partially completed.

 Consistency: Consistent, meaning any database constraints that must be true


before the transaction must also be true after the transaction

 Isolation: It means that the data used during the execution of a transaction
cannot be used by a second transaction until the first one is completed.

 Durability: It means that the changes are permanent. Thus, once a transaction is
committed, no subsequent failure of the database can reverse the effect of the
transaction.

What is a Transaction? Explain the Transaction State Diagram?

B.Sc II Year IV Sem C.AMBADAS Page 91

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Transaction: A Transaction is any action that reads from and/or writes to a database. It
is a logical unit of work that must be either entirely completed or aborted. Most real-
world database transactions are formed by two or more database requests. A database
request is the equivalent of a single SQL statement in an application program.
Transaction State Diagram: Following is the diagram that shows transaction states

1. Active State: A database transaction is in this state while its statements are being
executed. This is the initial state of every transaction.

2. Partially Committed Phase: A database transaction enters this state when its final
statement has been executed. But, it is still possible for the transaction to be aborted in
the case of hardware or output failures.

3. Failed State: A database transaction enters the failed state when its normal
execution can no longer proceed due to hardware or program errors.

4. Aborted State: A database transaction, if determined by the DBMS to have failed,


enters the aborted state. An aborted transaction must have no effect on the database.
The database will return to its consistent state when the aborted transaction has been
rolled back.

5. Committed State: A database transaction enters the committed state when


information has been stored or altered after completing its execution successfully.

Q) What is Database Architecture? (or)


How do you perform Transaction Management?

Database Architecture has the following components:

1. Transaction Manager: The transaction manager coordinates transactions on behalf


of application programs.

2. Scheduler: Transaction Manager communicates with the scheduler, the module


responsible for implementing a particular strategy for concurrency control. The
scheduler is sometimes referred to as the lock manager if the concurrency control
protocol is locking-based. The objective of the scheduler is to maximize concurrency
without allowing concurrently executing transactions to interfere with one another, and
so compromise the integrity or consistency of the database.

B.Sc II Year IV Sem C.AMBADAS Page 92

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


3. Recovery Manager: If a failure occurs during the transaction, then the database
could be inconsistent. It is the task of the recovery manager to ensure that the database
is restored to the state it was in before the start of the transaction, and therefore a
consistent state.

4. Buffer Manager: Finally, the buffer manager is responsible for the efficient transfer of
data between disk storage and main memory.

Q) DBMS Concurrency Control and Needs of concurrency control


Concurrency: The process of managing simultaneous operations on the
database without having them interfere with one another. But, this can
create several data integrity and consistency problems.
Concurrency control: The process of managing simultaneous operations
on the database without having them interfere with one another so that
data integrity is maintained and the operations do not interfere with each
other in a multi-user environment. The objective of concurrency control is
to ensure the serializability of transactions in a multi-user database
environment.
The three main problems associated with concurrency are:
 Lost Updates.
 Uncommitted Data.
 Inconsistent retrievals.

1) Lost Updates: The lost update problem occurs when two concurrent
transactions, T1 and T2, are updating the same data element and one of the
updates is lost (overwritten by the other transaction). This is a kind of
write/write conflict.
Example: Assume that there are two concurrent transactions, T1 and T2
working with X, and Initially, X=50. Then,
 As the Non-Interleaving execution performs the transactions as
desired, the value of X will be „600‟.

B.Sc II Year IV Sem C.AMBADAS Page 93

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


 But, in the case of Interleaving execution, First, T2 reads X (=50)
before its updation by T1; then T2 updates X to 500 (=50*100)
considering the previous value of X. Thus we lost the update by T1.

The process is shown below:


Non-Interleaving Execution Interleaving Execution

2) Uncommitted Data (Dirty-Read): The Uncommitted-data problem occurs when two


transactions, T1 and T2, are executed concurrently and the first transaction (T1) is
rolled back (due to a failure) after the second transaction (T2) has already accessed the
uncommitted data. It is a kind of write/read conflict and violates isolation property. This
is also called Dirty-Read problem.
Example: Assume that there are two concurrent transactions, T1 and T2 working with
X, and Initially, X=50. Then,
 As the Non-Interleaving execution performs the transactions as desired, the value
of X will be „600‟.
 But, in the case of Interleaving execution, First, T1 writes X (=60) and then T2
writes X (=600). But, if T1 fails and is rolled back, it has to restore its original
value i.e. 50. So, X will be 50.

The process is shown below:

3) Inconsistent Retrievals: Inconsistent retrievals occur when a transaction accesses


data before and after another transaction finish working with such data. For example,
an inconsistent retrieval would occur if transaction T1 calculates some summary
(aggregate) function over a set of data while another transaction (T2) is updating the
same data. The problem is that the transaction might read some data before they are

B.Sc II Year IV Sem C.AMBADAS Page 94

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


changed and other data after they are changed, thereby yielding inconsistent results.
This is a kind of write/read conflict.

Example: Assume that there are two concurrent transactions, T1 and T2 working with
X, Y, and Initially, X=10, and Y=20. Then,
 As the Non-Interleaving execution performs the transactions as desired, the value
of X will be „300‟.
 But, in the case of Interleaving execution, First, T1 reads X (=10) and adds it to
SUM(=10). Then T2 writes X (=100) and writes Y (=200). Now, if T1 reads Y (=200,
updated by T2) and adds it to SUM (=210). Thus, it is evident that the transactions
add before value of X and after value of Y to SUM resulting „210‟. This is nothing
but Inconsistent Retrieval.

The process is shown below:

What is Serializability? Discuss with aid of example to test the Conflicts in


Serializability?

Concurrent transactions need to be processed differently so that they do not interfere


with each other. When two or more transactions execute concurrently and they are
accessing same data there will be conflict among transactions. The selection of one
transaction‟s execution over the other may result undesirable consequences.
Serializability: Serializability ensures that a schedule for executing concurrent
transactions is equivalent to one that executes the transactions serially in some order
i.e. if one transaction were processed before another transaction, no interference would
occur. Serializability can be achieved by locking mechanism. But, not all the
transactions are serializable. There will be many conflicts in serializability which are
discussed below.
Read/Write Conflict Scenarios: All database operations might require READ/WRITE
operations that produce conflicts. The following table lists all the possible conflict-
scenarios when two concurrent transactions T1 and T2 access the same data. The
operations are in conflict when they access same data and at least one of them is a
WRITE operation.

B.Sc II Year IV Sem C.AMBADAS Page 95

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

Example: The following example shows write/write conflict seen in a problem called „lost
update’. The lost update problem occurs when two concurrent transactions, T1 and T2,
are updating the same data element and one of the updates is lost (overwritten by the
other transaction).
Assume that there are two concurrent transactions, T1 and T2 working with X, and
Initially, X=50. Then,
 In the case of Schedule „S1‟, the value of X will be „600‟.
 But, in the case of Schedule „S2‟, First, T2 reads X (=50) before its updation by T1;
then T2 updates X to 500 (=50*100) considering the previous value of X. Thus we
lost the update by T1.

The conflict is clearly evident that the above two schedules produce different results.

Recoverability of Schedule

Sometimes a transaction may not execute completely due to a software issue, system
crash or hardware failure. In that case, the failed transaction has to be rollback. But
some other transaction may also have used value produced by the failed transaction. So
we also have to rollback those transactions.

B.Sc II Year IV Sem C.AMBADAS Page 96

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

The above table 1 shows a schedule which has two transactions. T1 reads and writes the
value of A and that value is read and written by T2. T2 commits but later on, T1 fails.
Due to the failure, we have to rollback T1. T2 should also be rollback because it reads
the value written by T1, but T2 can't be rollback because it already committed. So this
type of schedule is known as irrecoverable schedule.

Irrecoverable schedule: The schedule will be irrecoverable if Tj reads the updated value
of Ti and Tj committed before Ti commit.

The above table 2 shows a schedule with two transactions. Transaction T1 reads and
writes A, and that value is read and written by transaction T2. But later on, T1 fails. Due
to this, we have to rollback T1. T2 should be rollback because T2 has read the value
written by T1. As it has not committed before T1 commits so we can rollback transaction
T2 as well. So it is recoverable with cascade rollback.

Recoverable with cascading rollback: The schedule will be recoverable with cascading
rollback if Tj reads the updated value of Ti. Commit of Tj is delayed till commit of Ti.

B.Sc II Year IV Sem C.AMBADAS Page 97

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


The above Table 3 shows a schedule with two transactions. Transaction T1 reads and
write A and commits, and that value is read and written by T2. So this is a cascade less
recoverable schedule.

Locking
Locking : A procedure used to control concurrent access to data. When one transaction
is accessing the database, a lock may deny access to other transactions to prevent
incorrect results.
Locking Methods: Locking methods are the most widely used approach to ensure
serializability of concurrent transactions. There are several variations, but all share the
same fundamental characteristic, namely that a transaction must claim a shared (read)
or exclusive (write) lock on a data item before the corresponding database read or write
operation. DBMS uses different lock types:
1. Shared lock
2. Exclusive lock

1. Exclusive Lock: If a transaction has an exclusive lock on a data item, it can both
read and update the item. This mode of locking provides an exclusive use of data item to
one particular transaction. The exclusive mode of locking is also called an UPDATE or a
WRITE lock.

2. Shared Lock: The shared lock is also called as a Read Lock. This mode allows several
transactions to access the same item X only for reading purpose. Thus, any number of
transactions can concurrently place a shared lock and read a data item, but none of
these transactions can update the data item. A data item locked in the shared mode
cannot be locked in the exclusive mode until the shared lock is released. A data item
locked in the exclusive mode cannot be locked in the shared mode until the exclusive
lock on the data item is released.

Lock States: Using the shared/exclusive locking concept, a lock can have three states:
unlocked, shared (read), and exclusive (write).
Lock Operations: Three lock operations exist: READ_LOCK (to check the type of lock),
WRITE_LOCK (to issue the lock), and UNLOCK (to release the lock).
Lock Problems: Locks can lead to two major problems:
 The resulting transaction schedule might not be Serialisable.
 The schedule might create deadlocks.

Q) Two-Phase Locking
Two-phase locking defines how transactions acquire and release locks. Two-phase
locking ensures serializability, but it does not prevent deadlocks. The two phases are:
1. A growing phase: A phase in which a transaction acquires all required locks but
cannot release any locks. Once all locks have been acquired, the transaction is in its
locked point.
2. A shrinking phase: A phase in which a transaction releases all locks and cannot
obtain any new locks.

B.Sc II Year IV Sem C.AMBADAS Page 98

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


The two-phase locking protocol is governed by the following rules:
• A transaction must acquire a lock on an item before operating on the item. The lock
may be read or write, depending on the type of access method.
 Once the transaction releases the lock, it can never acquire any new locks.
• No data are affected until all locks are obtained i.e. until the transaction is in its
locked point.
Following are the steps for the execution of a transaction in two phase locking:
1. First, the transaction acquires all of the locks it needs until it reaches its locked point.
2. When the locked point is reached, the data are modified.
3. Finally, the transaction is completed as it releases all of the locks it acquired

Example: The following table shows how a transaction executes in the case of normal
locking and two-phase locking:

Write short notes on Deadlocks. Explain the Techniques to Control Deadlocks?


Deadlock: Deadlock occurs when two transactions wait indefinitely for each other to
unlock data. For example, a deadlock occurs when two transactions, T1 and T2, exist in
the following mode:
T1 = access data items X and Y
T2 = access data items Y and X
If T1 has not unlocked data item Y, T2 cannot begin; if T2 has not unlocked data item X,
T1 cannot continue. Consequently, T1 and T2 each wait for the other to unlock the
required data item. Such a deadlock is also known as a deadly embrace.

B.Sc II Year IV Sem C.AMBADAS Page 99

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


The example used only two concurrent transactions to demonstrate a deadlock
condition. But, in a real world DBMS, many more transactions can be executed
simultaneously, thereby increasing the chances of generating deadlocks. Deadlocks can
occur only in the case of exclusive locks, not in the case of shared locks.
Three basic techniques to control deadlocks are:
• Deadlock prevention: A transaction requesting a new lock is aborted when there is
the possibility that a deadlock can occur. If the transaction is aborted, all changes made
by this transaction are rolled-back and all locks obtained by the transaction are
released. The transaction is then rescheduled for execution.

Deadlock detection: The DBMS periodically tests the database for deadlocks. If a
deadlock is found, one of the transactions (the „victim‟) is aborted (rolled back and
restarted) and the other transaction continues.
• Deadlock avoidance: The transaction must obtain all of the locks it needs before it can
be executed. This technique avoids the rollback of conflicting transactions by requiring
that locks to be obtained in succession.
The choice of the best deadlock control method to use depends on the database
environment. For example, if the probability of deadlocks is low, „deadlock detection’ is
recommended. However, if the probability of deadlocks is high, „deadlock prevention‟ is
recommended. If response time is not important, ‘deadlock avoidance’ might be
preferable

Q) Explain Concurrency Control with Time Stamping Methods?


Time Stamping: A concurrency control protocol that orders transactions in such a way
that older transactions, transactions with smaller timestamps, get priority in the event of
conflict.
Time Stamping Method: The time stamping approach assigns a unique time stamp to
each transaction for scheduling concurrent transactions. The time stamp value decides
an order in which transactions are submitted to the DBMS.
• Time stamps must have two properties:
 Uniqueness: This ensures that the timestamp value is unique to each transaction.
 Monotonicity: This ensures that the stamp values always increase.
• All database operations (READ and WRITE) within the same transaction must have the
same time stamp.
• The disadvantage of the time stamping approach is that each value stored in the
database requires two additional time stamp fields: one for the last time the field was
read and one for the last update. Time stamping thus increases memory needs and
demands a lot of system resources.
• There are two approaches that use time-stamping methods to control concurrency.

1. WAIT/DIE Scheme: In the wait/die scheme, the older transaction waits for the
younger to complete and release locks.
 If the transaction requesting the lock is the older of the two transactions, it will
wait until the other transaction is completed and the locks are released.
 If the transaction requesting the lock is the younger of the two transactions, it will
die (roll back) and is rescheduled using the same time stamp.
Example: Assume that there are three Transactions T10, T20 and T30 with timestamps
10, 20 and 30 respectively i.e. T10 is older than T20 and T30 is younger than T20. Also,
assume that T20 locked a data item „X‟. In the case,
• when T10 requests a lock on „X‟, T10 waits as it is older than T20, and
• when T30 requests a lock on „X‟, T30 is aborted and rolled back as it is younger than
T20
B.Sc II Year IV Sem C.AMBADAS Page 100

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System

2. WOUND/WAIT Scheme: In the wound/wait scheme, the older


transaction aborts the younger transaction and reschedules it.
 If the transaction requesting the lock is the older of the two
transactions, it will preempt (wound) the younger transaction (by
rolling it back). T1 preempts T2 when T1 rolls back T2. The younger
transaction is rescheduled using the same time stamp.
 If the transaction requesting the lock is the younger of the two
transactions, it will wait until the other transaction is completed and
the locks are released.

Example: Assume that there are three Transactions T10, T20 and T30 with
timestamps 10, 20 and 30 respectively i.e. T10 is older than T20 and T30 is
younger than T20. Also, assume that T20 locked a data item „X‟. In the
case,
• when T10 requests a lock on „X‟, T20 is aborted and rolled back - as T10
being older, preempts T20
• when T30 requests a lock on „X‟, T30 waits as it is younger than T20

Q) Multisession Timestamp Ordering

As we have seen above, a problem with 2PL is that it can lead to deadlocks. Reed's multi
version timestamp ordering scheme solves this problem by ordering transactions and
aborting transactions that access data out of order. It also increases the concurrency in
the system by never making an operation block (though it does abort transactions.)

The basic idea in this scheme is to assign transactions timestamps when they are
started, which are used to order these transactions. If two transactions access data
items in an order that is inconsistent with their time stamps, then one of them is
aborted.

Consider again the following schedule

B.Sc II Year IV Sem C.AMBADAS Page 101

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Assume T1 entered the system before T2. Then the system will try to serialize them in
this order. When transaction T1 tries to read p2 written earlier by T2, it aborts one of
them as they are out of the serialization order being remembered.

A possible implementation of this approach is to require each data item to remember the
timestamp of the last transaction that wrote the item. If a transaction with an earlier
timestamp tries to read or write to this item, then it is aborted.

Unfortunately, this scheme is too conservative to Reed's scheme. The problem with it is
that it does not recognize that we can concurrently have transactions working with
different versions of a data item that can be serialized.

Therefore, Reed's algorithm is more complicated. As with the simpler scheme given
above, it assigns transactions timestamps when they are started, which are used to
order these transactions. Moreover, it associates each data item with timestamped
versions and associates each version with readtimestamps. A readtimestamp is
associated with a data item whenever a transaction reads the data item and is the same
as the timestamp of the reading transaction. A timestamped version is created whenever
a transaction writes a new value to the data item and has the timestamp of the writing
transaction. The following steps occur when a transaction accesses the database:

If the operation is a read, then it is allowed, and the version read is the one with the
largest timestamp less than the timestamp of the reading transaction. The timestamp of
the reading transaction is added to the item.

If the operation is a write, then a new version of the data item is created with the
timestamp of the writing transaction as long as no transaction with a more recent
timestamp has read a version of the item with an older timestamp than that of the
writing transaction. If this check fails, the writing transaction is aborted and restarted.

By making sure that T1 does not read the latest version of p, the scheme supports
serializability. The problem with this scheme is the cost of keeping multiple versions and
associated time stamps.

Q) Explain Concurrency Control with Optimistic Methods?


Concurrency Control with Optimistic Methods: Optimistic techniques are based on
the assumption that conflict is rare and that it is more efficient to allow transactions to
proceed without imposing delays to ensure serializability. The optimistic approach
requires neither locking nor time stamping techniques. Instead, a transaction is
executed without restrictions until it is committed. The optimistic approach is acceptable
for most read or query database systems that require few update transactions. In this
approach, each transaction moves through two or three phases, referred to as read,
validation, and write.
• Read Phase: This extends from the start of the transaction until immediately before the
commit. The transaction reads the values of all data items t needs from the database
and stores them in local variables. Updates are applied to a local copy of the data, not to
the database itself.
• Validation Phase: During the validation phase, the transaction is validated to ensure
that the changes made will not affect the consistency of the database. If the validation

B.Sc II Year IV Sem C.AMBADAS Page 102

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


test is positive, the transaction goes to the write phase. If the validation test is negative,
the transaction is restarted and the changes are discarded.
• Write Phase: During the write phase, the changes are permanently applied to the
database.

Q) Explain Granularity of Data Items?

Granularity: The size of data items chosen as the unit of protection by a concurrency
control protocol.
Lock Granularity: An important consideration in implementing concurrency control is
choosing the locking level. Lock granularity indicates the level of lock use. Locking can
take place at the following levels: data-base, table, page, row, or even field (attribute).
 Database Level: In a database-level lock, the entire database is locked, thus
preventing the use of any tables in the database by transaction T2 while transaction
T1 is being executed. This level of locking is good for batch processes, but it is
unsuitable for multiuser DBMSs.
 Table Level: In a table-level lock, the entire table is locked, preventing access to any
row by transaction T2 while transaction T1 is using the table. However, two
transactions can access the same database as long as they access different tables.
Table-level locks are less restrictive than database-level locks.
 Page level lock: The physical storage block (or page) containing a requested record is
locked. This level is the most commonly implemented locking level. A page will be a
fixed size (4K, 8K, etc.) and may contain records of one or more tables. Page-level
locks are currently the most frequently used multiuser DBMS locking method.
 Row Level Lock: A row-level lock is much less restrictive than other locks. The
DBMS allows concurrent transactions to access other rows of the same table even
when the rows belong to the same table.
 Field Level Lock: The field-level lock allows concurrent transactions to access the
same row as long as they required use of different fields (attributes) within that row.
It is rarely implemented in a DBMS because it requires an extremely high level of
computer overhead.

Q)What is Database Recovery? The Need for Recovery?

B.Sc II Year IV Sem C.AMBADAS Page 103

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


Database Recovery: The process of restoring the database to a correct state in the event
of failure. Reliability refers to both the resilience of the DBMS to various types of failure
and its capability to recover from them.
The Need for Recovery: The storage of data generally includes four different types of
media with an increasing degree of reliability: main memory, magnetic disk, magnetic
tape, and optical disk. Main memory is volatile storage that usually does not survive
system crashes. Magnetic disks provide online nonvolatile storage. Compared with main
memory, disks are more reliable and much cheaper, but slower by three to four orders of
magnitude. Magnetic tape is an offline nonvolatile storage medium, which is far more
reliable than disk and fairly inexpensive, but slower, providing only sequential access.
Optical disk is more reliable than tape, generally cheaper, faster, and providing random
access. Main memory is also referred to as primary storage and disks and tape as
secondary storage. Stable storage represents information that has been replicated in
several nonvolatile storage media (usually disk) with independent failure modes.
There are many different types of failure that can affect database processing, each of
which has to be dealt with in a different manner. Some failures affect main memory only,
while others involve nonvolatile (secondary) storage. Among the causes of failure are:
• System crashes due to hardware or software errors, resulting in loss of main memory
• Media failures, such as head crashes or unreadable media, resulting in the loss of
parts of secondary storage
 Application software errors, such as logical errors in the program that is accessing
the database, that cause one or more transactions to fail
• Natural physical disasters, such as fires, floods, earthquakes, or power failures
• Carelessness or unintentional destruction of data or facilities by operators or users
• Sabotage, or intentional corruption or destruction of data, hardware, or software
facilities.

Q) Write short notes on Transaction Recovery?


Database transaction recovery uses data in the transaction log to recover a database
from an inconsistent state to a consistent state. Transaction recovery procedures
generally make use the following two techniques.
1. Deferred-write (Deferred-update): Transaction operations do not immediately update
the database. Instead, all changes are written to the transaction log. The database is
updated only after the transaction reaches its commit point using information from the
transaction log. If a transaction fails before it reaches its commit, no changes need to be
done.

2. Write-through (Immediate Update): The database is immediately updated by


transaction operations during the transaction‟s execution, even before the transaction
reaches its commit point. The transaction log is also updated. If a transaction fails, the
database uses the log information to roll back the database.

Q) What are Recovery Facilities?


A DBMS should provide the following facilities to assist with recovery:
• Backup Mechanism: Which makes periodic backup copies of the database. The
backup copy of the database can be used in the event that the database has been
damaged or destroyed. A backup can be a complete copy of the entire database or an
incremental backup, consisting only of modifications made since the last complete or
incremental backup. Typically, the backup is stored on offline storage, such as an
optical disk.
• Logging Facilities: which keep track of the current state of transactions and database
changes. The log may contain the following data:

B.Sc II Year IV Sem C.AMBADAS Page 104

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


• Transaction records, containing:
• transaction identifier
• type of log record (transaction start, insert, update, delete, abort, commit)
• identifier of data item affected by the database action (insert, delete, and
update operations)
• before-image of the data item, that is, its value before change (update and
delete operations only)
• after-image of the data item, that is, its value after change (insert and
update operations only)
• log management information, such as a pointer to previous and next log
records for that transaction (all operations).
• Checkpoint Facility: Which enables updates to the database that are in progress to
be made permanent. Checkpoints are scheduled at predetermined intervals and involve
the following operations:
• writing all log records in main memory to secondary storage;
• writing the modified blocks in the database buffers to secondary storage;
• writing a checkpoint record to the log file. This record contains the identifiers of all
transactions that are active at the time of the checkpoint.
• Recovery Manager, which allows the system to restore the database to a consistent
state following a failure.
Q) Recovery Techniques

1. Transaction failure: A transaction needs to abort once it fails to execute or once it


reaches to any further extent from wherever it can‟t go to any extent further. This
is often known as transaction failure wherever solely many transactions or
processes are hurt. The reasons for transaction failure are:
 Logical errors
 System errors
1. Logical errors: Where a transaction cannot complete as a result of its code error
or an internal error condition.
2. System errors: Wherever the information system itself terminates an energetic
transaction as a result of the DBMS isn‟t able to execute it, or it‟s to prevent due
to some system condition. to Illustrate, just in case of situation or resource
inconvenience, the system aborts an active transaction.
3. System crash: There are issues − external to the system − that will cause the
system to prevent abruptly and cause the system to crash. For instance,
interruptions in power supply might cause the failure of underlying hardware or
software package failure. Examples might include OS errors.
4. Disk failure: In early days of technology evolution, it had been a typical drawback
wherever hard-disk drives or storage drives accustomed to failing oftentimes. Disk
failures include the formation of dangerous sectors, unreachability to the disk,
disk crash or the other failure, that destroys all or a section of disk storage.

Q) What is Nested Transaction Model and it’s Advantages?


A Nested transaction model is viewed as a collection of related sub-transactions, each of
which may also contain any number of sub-transaction. The nested transaction model
was introduced by Moss (1981). In this model, the complete transaction forms a tree, or
hierarchy, of sub-transactions. There is a top-level transaction that can have a number
of child transactions.

B.Sc II Year IV Sem C.AMBADAS Page 105

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


However, a transaction abort at one level does not have to effect a transaction in
progress at a high level. Instead, a parent is allowed to perform its own recovery in one of
the following ways.
• Retry the sub-transaction.
• Ignore the failure, in which case the sub-transaction id deemed to be non-vital.

Advantages of Nested transaction model:


The main advantages of the Nested Transaction Model are its support for:
Modularity: A transaction can be decomposed into a number of sub-transactions for the
purposes of concurrency and recovery.
Granularity for concurrency control and recovery: Occurs at the level of the sub-
transaction rather than the transaction.
Infra-transaction parallelism: Sub-transactions can execute concurrently. Infra-
transaction recovery: Uncommitted sub-transactions can be aborted and rolled back
without any side effects to other sub-transactions.

Q) Database Security and Threats

Database Security is the mechanism that protects the database against intentional or
accidental threats. Breaches of security may affect other parts of the system, which may
in turn affect the database. Database security encompasses hardware, software, people,
and data. To effectively implement security requires appropriate controls. The reason for
this turnaround is the increasing amounts of crucial corporate data being stored on
computer and the acceptance that any loss or unavailability of this data could prove to
be disastrous.
Database security covers the following issues:
• Theft and Fraud: It not only affect the database environment but also the entire
organization.
• Confidentiality / Privacy: Confidentiality refers to the need to maintain secrecy over
data that is critical to the organization. Privacy refers to the need to protect data about
individuals.
• Loss of Integrity: Loss of data integrity results in invalid or corrupted data, which
may seriously affect the operation of an organization.
• Loss of Availability: Loss of availability means that the data, or the system, or both
cannot be accessed, Which can seriously affect an organization‟s financial performance.
In some cases, events that cause a system to be unavailable may also cause data
corruption.

Measures of Control

The measures of control can be broadly divided into the following categories −
 Access Control − Access control includes security mechanisms in a database
management system to protect against unauthorized access. A user can gain
access to the database after clearing the login process through only valid user
accounts. Each user account is password protected.
 Flow Control − Distributed systems encompass a lot of data flow from one site to
another and also within a site. Flow control prevents data from being transferred
in such a way that it can be accessed by unauthorized agents. A flow policy lists
out the channels through which information can flow. It also defines security
classes for data as well as transactions.

B.Sc II Year IV Sem C.AMBADAS Page 106

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


 Data Encryption − Data encryption refers to coding data when sensitive data is to
be communicated over public channels. Even if an unauthorized agent gains
access of the data, he cannot understand it since it is in an incomprehensible
format.

What are Computer Based Controls?


The types of countermeasure to threats on computer systems range from physical
controls to administrative procedures. The following are the computer-based security
controls for a multi-user environment.
• Authorization
• Access controls
• Views
• Backup and Recovery
• Integrity
• Encryption
• RAID Technology
Authorization: The granting of a right or privilege that enables a subject to have
legitimate access to a system or a system‟s object. Authorization controls can be built
into the software and govern not only what system or object a specified user can access,
but also what the user may do with it. The process of authorization involves
authentication of subjects requesting access to objects, where “subject” represents a
user or program and “object” represents a database table, view, procedure, trigger, or
any other object that can be created within the system.
(i) Authentication: A mechanism that determines whether a user is who he or she claims
to be. To authenticate a user in the database environment, two elements are required.
(ii) User Id
(iii) Authentication token

Access Controls: A privilege allows a user to create or access (that is read, write, or
modify) some database object (such as a relation, view, or index) or to run certain DBMS
utilities. Privileges are granted to users to accomplish the tasks required for their jobs.
As excessive granting of unnecessary privileges can compromise security.
Views: A view is the dynamic result of one or more relational operations operating on the
base relations to produce another relation. A view is a virtual relation that does not
actually exist in the database, but is produced upon request by a particular user, at the
time of request. The view mechanism provides a powerful and flexible security
mechanism by hiding parts of the database from certain users. The user is not aware of
the existence of any attributes or rows that are missing from the view.
Backup and Recovery: The process of periodically copying of the database and log file
(and possibly programs) to offline storage media is known as Backup.
A DBMS should provide logging facilities, sometimes referred to as journaling, which
keep track of the current state of transactions and database changes, to provide support
for recovery procedures. The advantage of journaling is that in the event of a failure, the
database can be recovered to its last known consistent state using a backup copy of the
database and the information contained in the log file.
Integrity: Integrity constraints also contribute to maintaining a secure database system
by preventing data from becoming invalid, and hence giving misleading or incorrect
results.
Encryption: The encoding of the data by a special algorithm that renders the data
unreadable by any program without the decryption key is Enryption. To transmit data
securely over
B.Sc II Year IV Sem C.AMBADAS Page 107

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


insecure networks requires the use of a cryptosystem, which includes:
• an encryption key to encrypt the data (plaintext)
• an encryption algorithm that with the encryption key transforms the plaintext
into ciphertext
• a decryption key to decrypt the ciphertext
• a decryption algorithm that with the decryption key transforms the ciphertext
back into plaintext.

RAID Technology: The hardware that the DBMS is running on must be fault-tolerant,
meaning that the DBMS should continue to operate even if one of the hardware
components fails. This suggests having redundant components that can be seamlessly
integrated into the working system whenever there is one or more component failures.
The solution is the use of Redundant Array of Independent Disks (RAID) technology.
RAID works on having a large disk array comprising an arrangement of several
independent disks that are organized to improve reliability and at the same time
increase performance.

Q)Redundant Array of Independent Disks(RAID)


RAID or Redundant Array of Independent Disks, is a technology to connect multiple
secondary storage devices and use them as a single storage media.
RAID consists of an array of disks in which multiple disks are connected together to
achieve different goals. RAID levels define the use of disk arrays.

RAID 0
In this level, a striped array of disks is implemented. The data is broken down into
blocks and the blocks are distributed among disks. Each disk receives a block of data to
write/read in parallel. It enhances the speed and performance of the storage device.
There is no parity and backup in Level 0.

RAID 1
RAID 1 uses mirroring techniques. When data is sent to a RAID controller, it sends a
copy of data to all the disks in the array. RAID level 1 is also called mirroring and
provides 100% redundancy in case of a failure.

RAID 2
RAID 2 records Error Correction Code using Hamming distance for its data, striped on
different disks. Like level 0, each data bit in a word is recorded on a separate disk and
B.Sc II Year IV Sem C.AMBADAS Page 108

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


ECC codes of the data words are stored on a different set disks. Due to its complex
structure and high cost, RAID 2 is not commercially available.

RAID 3
RAID 3 stripes the data onto multiple disks. The parity bit generated for data word is
stored on a different disk. This technique makes it to overcome single disk failures.

RAID 4
In this level, an entire block of data is written onto data disks and then the parity is
generated and stored on a different disk. Note that level 3 uses byte-level striping,
whereas level 4 uses block-level striping. Both level 3 and level 4 require at least three
disks to implement RAID.

RAID 5
RAID 5 writes whole data blocks onto different disks, but the parity bits generated for
data block stripe are distributed among all the data disks rather than storing them on a
different dedicated disk.

B.Sc II Year IV Sem C.AMBADAS Page 109

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com


www.android.universityupdates.in | www.universityupdates.in | www.ios.universityupdates.in

Database Management System


RAID 6
RAID 6 is an extension of level 5. In this level, two independent parities are generated
and stored in distributed fashion among multiple disks. Two parities provide additional
fault tolerance. This level requires at least four disk drives to implement RAID.

B.Sc II Year IV Sem C.AMBADAS Page 110

www.android.previousquestionpapers.com | www.previousquestionpapers.com | www.ios.previousquestionpapers.com

You might also like