DBMS Unit-I
DBMS Unit-I
UNIT II
Entity-Relationship Model:
Introduction, the building blocks of an entity relationship diagram,
classification of entity sets, attribute classification, relationship degree,
relationship classification, reducing ER diagram to tables, enhanced entity-
relationship model (EER model), generalization and specialization, IS A
relationship and attribute inheritance, multiple inheritance, constraints on
specialization and generalization, advantages of ER modeling.
UNIT III
Relational Model:
Introduction, CODD Rules, relational data model, concept of key, relational
integrity, relational algebra, relational algebra operations, advantages of
relational algebra, limitations of relational algebra, relational calculus, tuple
relational calculus, domain relational Calculus (DRC), Functional dependencies
and normal forms up to 3rd normal form.
UNIT IV
Structured Query Language:
Introduction, History of SQL Standard, Commands in SQL, Data Types in SQL,
Data Definition Language, Selection Operation, Projection Operation,
Aggregate functions, Data Manipulation Language, Table Modification
Commands, Join Operation, Set Operations, View, Sub Query.
UNI
TV
PL/S
QL:
Introduction, Shortcomings of SQL, Structure of PL/SQL, PL/SQL Language
Elements, Data Types, Operators Precedence, Control Structure, steps to
Create a PL/SQL, Program, Iterative Control, Procedure, Function, Database
Triggers, Types of Triggers.
UNIT I
Overview of Database Management System
1. Write about Overview of Database Management System.
Introduction:
DBMS stands for Database Management System.
We break it like this DBMS = Database + Management System.
Database is a collection of data.
Management System is a set of programs to store and retrieve those
data.
DBMS is a collection of inter – related data and set of programs to store
& access those data in an easy and effective manner.
Need of DBMS:
Database systems are basically developed for large amount of data.
When dealing with huge amount of data, there are two things
that require optimization:
1. Storage of data
2. Retrieval of data.
Storage:
According to the principles of database systems, the data is stored in
such a way that it acquires lot less space as the redundant data
(duplicate data) has been removed before storage.
Let’s take a layman example to understand this: In a banking system,
suppose a customer is having two accounts, one is saving account
and another is salary account.
Let’s say bank stores saving account data at one place (these places are
called tables we will learn them later) and salary account data at
another place, in that case if the customer information such as customer
name, address etc. are stored at both places then this is just a wastage
of storage (redundancy/ duplication of data), to organize the data in a
better way the information should be stored at one place and both the
accounts should be linked to that information somehow. The same thing
we achieve in DBMS.
Information:
Information is organized or classified data, which has some meaningful
values for the receiver.
Information is the processed data on which decisions and actions are
based.
For the decision to be meaningful, the processed data must qualify for
the following characteristics –
1. Timely – Information should be available when required.
2. Accuracy – Information should be accurate.
3. Completeness – information should be complete.
Information is needed to:
1. To gain knowledge about the surroundings, and whatever is
happening in the society and universe.
2. To keep the system up to date.
3. To know about the rules and regulations and bye laws of society,
local government, provincial and central government, associations,
client etc. as ignorance is no bliss.
4. Based on above three, to arrive at a particular decision for planning
current and prospective actions in process of forming, running and
protecting a process or system.
Database: -
A Database is an organized collection of data, so that it can be easily
accessed and managed.
You can organize data into tables, rows, columns, and index it to make it
easier to find relevant information.
Database handlers create a database in such a way that only one set of
software program provides access of data to all the users.
The main purpose of the database is to operate a large amount of
information by storing, retrieving, and managing data.
There are many dynamic websites on the World Wide Web nowadays
which are handled through databases. For example, a model that checks
the availability of rooms in a hotel. It is an example of a dynamic website
that uses a database.
There are many databases available like MySQL, Sybase, Oracle,
MongoDB, Informix, PostgreSQL, SQL Server, etc.
Modern databases are managed by the database management system
(DBMS).
SQL or Structured Query Language is used to operate on the data stored
in a database. SQL depends on relational algebra and tuple relational
calculus.
A cylindrical structure is used to display the image of a database.
5. What is DBMS
Approach? A.
A Database is defined to be a collection of related information stored in
a manner that many users share it for different purposes.
The content of a database is obtained by integrating data from all the
different sources at a centralized location in an organization. Such data
is made available to all users as per the requirements and redundant
data can be eliminated or at least minimized.
The Database Management System (DBMS) governs to create an
environment in which end users have better access to more and better
managed data than they did before the DBMS become the data
management standard.
Some of the common database applications are student database
system, business inventory, accounting information, organization data
etc. Some commercially available DBMS are ORACLE, DB2, and Sybase
etc.
Some commercially available is a combination of hardware and software
that can be used to set up and monitor a database and can manage the
updating and retrieval of database that has been stored in it.
Most database management systems support the following facilities /
capabilities:
Creation, modification and deletion of data files.
Addition, modification, deletion of data.
Retrieving of data collectively or selectively.
Sorting or Indexing of data.
Creation of input forms and output reports.
Manipulation of stored data with some mathematical functions,
support for concurrent transactions.
To maintain data integrity and security.
To create an environment for data warehousing and Data mining.
9
Network database:
A network databases are mainly used on large digital computers.
If there are more connections, then this database is efficient.
They are similar to hierarchical database; they look like a interconnected
network of records.
A Network database management system is a system where the data
elements maintain one to one relationship (1: 1) or many to many
relationships (N: N).
It also has a hierarchical structure, but the data is organized like a graph
and it is allowed to have more than one parent for one child record.
Example
Teachers can teach in multiple departments. This is shown below −
10
Relational Databases:
A relational database management system (RDBMS) is a system where
data is organized in two-dimensional tables using rows and columns.
This is one of the most popular data models which is used in industries.
It is based on SQL.
Every table in a database has a key field which uniquely identifies each
record.
This type of system is the most widely used DBMS.
Relational database management system software is available for
personal computers, workstation and large mainframe systems.
For example − Oracle Database, MySQL, Microsoft SQL Server etc.
11
8. What are the Advantages and Disadvantages of DBMS?
Advantages of DBMS:
The advantages of the DBMS are explained below −
Redundancy problem can be solved:
In the File System, duplicate data is created in many places because all
the programs have their own files which create data redundancy
resulting in wastage of memory.
In DBMS, all the files are integrated in a single database. So there is no
chance of duplicate data.
For example: A student record in a library or examination can contain
duplicate values, but when they are converted into a single database, all the
duplicate values are removed.
Has a very high security level:
Data security level is high by protecting your precious data from
unauthorized access.
Only authorized users should have the grant to access the database with
the help of credentials.
Presence of Data integrity:
Data integrity makes unification of so many files into a single file.
DBMS allows data integrity which makes it easy to decrease data
duplicity Data integration and reduces redundancy as well as data
inconsistency.
Support multiple users:
DBMS allows multiple users to access the same database at a time
without any conflicts.
Avoidance of inconsistency:
DBMS controls data redundancy and also controls data consistency.
Data consistency is nothing but if you want to update data in any files
then all the files should not be updated again.
In DBMS, data is stored in a single database so data becomes more
consistent in comparison to file processing systems.
Shared data:
Data can be shared between authorized users of the database in DBMS.
All the users have their own right to access the database.
Admin has complete access to the database. He has a right to assign
users to access the database.
Enforcement of standards:
As DBMS have central control of the database.
So, a DBA can ensure that all the applications follow some standards
such as format of data, document standards etc.
These standards help in data migrations or in interchanging the data.
Any unauthorized access is restricted:
Unauthorized persons are not allowed to access the database because
of security credentials.
Provide backup of data:
Data loss is a big problem for all the organizations.
In the file system users have to back up the files in regular intervals
which lead to waste of time and resources.
DBMS solves this problem of taking backup automatically and recovery
of the database.
Disadvantages of DBMS:
The disadvantages of DBMS are as follows:
Complexity
The provision of the functionality that is expected of a good DBMS
13
makes the DBMS an extremely complex piece of software.
Database designers, developers, database administrators and end-users
must understand this functionality to take full advantage of it.
Failure to understand the system can lead to bad design decisions,
which leads to a serious consequence for an organization.
Size:
The functionality of DBMS makes use of a large piece of software which
occupies megabytes of disk space.
Performance:
Performance may not run as fast as desired.
Higher impact of a failure:
The centralization of resources increases the vulnerability of the system
because all users and applications rely on the availability of DBMS, the
failure of any component can bring operation to halt.
Cost of DBMS:
The cost of DBMS varies significantly depending on the environment
and functionality provided.
There is also the recurrent annual maintenance cost.
9. Distinguish between File Based
System and DBMS? A.
FILE SYSTEM DBMS
Used to manage and organize the A software to store and retrieve the
files stored in the hard disk of the user’s data
computer
Less complex, does not support More complexity in managing the data,
complicated transactions easier to implement complicated
transactions
Hierarchical Model:
The Hierarchical Model was the first database management system
model.
This concept uses a hierarchical tree structure to organize the data.
The hierarchy begins at the root, which contains root data, and then
grows into a tree as child nodes are added to the parent node.
This model accurately depicts several real-world relationships such as
food recipes, website sitemaps, and so on.
Example
The following diagram depicts the relationship between the shoes available on
a shopping website:
Network Model:
Like the hierarchical data model, this model is fairly simple and easy to
create.
It’s intended to be a flexible way of representing items and their
interactions.
The main difference between this model and the hierarchical model is that
any record can have several parents.
It uses a graph instead of a hierarchical tree.
Example
We can observe that the node student has two parents, CSE Department and
Library, in the example below. In the hierarchical model, this was previously
impossible.
Entity-Relationship Model
A high-level data model diagram is the entity-relationship model or ER
Model.
We depict the real-world problem in visual form in this model to make it
easier for stakeholders to comprehend.
The developers can also quickly grasp the system by simply looking at
the ER Diagram.
Components of an ER Diagram
The ER diagram is a visual representation of an ER Model. The three
components of an ER diagram are as follows:
1. Entities
An entity is a real-life concept. It could be a person, a location, or even
an idea.
A school management system, for example, has entities such as
teachers, students, courses, buildings, departments, and so on.
2. Attributes
An attribute is a real-world property that exists in an entity.
For example, the entity teacher has properties such as teacher salary, id,
age, and so on.
3. Relationship
The relationship between two traits describes how they are linked.
A teacher, for example, works for a department.
Example
Relationship Model:
The relational model represents DB in the form of a collection of various
relations.
This relation refers to a table of various values. And every row present in
the table happens to denote some real-world entities or relationships.
The names of tables and columns help us interpret the meaning of the
values present in every row of the table.
This data gets represented in the form of a set of various relations. Thus,
in the relational model, basically, this data is stored in the form of tables.
However, this data’s physical storage is independent of its logical
organization.
Popular Relational Database Management Systems:
IBM – DB2 and Informix Dynamic Server
Oracle – Oracle and RDB
Microsoft – SQL Server and Access
Illustration of the Relational Model
A relational model represents how we can store data in Relational
Databases.
Here, a relational database stores information in the form of relations or
tables.
Now, let us consider a relation EMPLOYEE with attributes ID_NO, NAME,
ADDRESS, ROLL_NO, and AGE shown in this table:
EMPLOYEE
ID_NO NAME ADDRESS ROLL_NO AGE
C1 RIYA DELHI 15 20
C2 SUNITA GURGAON 16 22
C3 ASHWANI ROHTAK 12 18
C4 PREETI DELHI 25
Software
A set of programs used to control and manage the overall database. This
includes the DBMS software itself, the Operating System, the network
software being used to share the data among users, and the application
programs used to access data in the DBMS.
Hardware
consists of a set of physical electronic devices such as computers, I/O devices,
storage devices, etc., this provides the interface between computers and the
real world systems.
Data
DBMS exists to collect, store, process and access data, the most important
component. The database contains both the actual or operational data and the
metadata.
Procedures
These are the instructions and rules that assist on how to use the DBMS, and in
designing and running the database, using documented procedures, to guide
the users that operate and manage it.
Data Manager
Also called the cache manager, this is responsible for handling of data in the
database, providing a recovery to the system that allows it to recover the data
after a failure.
Database Engine
The core service for storing, processing, and securing data, this provides
controlled access and rapid transaction processing to address the
requirements of the most demanding data consuming applications. It is often
used to create relational databases for online transaction processing or online
analytical processing data.
Data Dictionary
this is a reserved space within a database used to store information about the
database itself. A data dictionary is a set of read-only table and views,
containing the different information about the data used in the enterprise to
ensure that database representation of the data follow one standard as
defined in the dictionary.
Report Writer
also referred to as the report generator, it is a program that extracts
information from one or more files and presents the information in a specified
format. Most report writers allow the user to select records that meet certain
conditions and to display selected fields in rows and columns, or also format
the data into different charts.
20
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
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
21
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.
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.
Fig: 3-tier Architecture
3. External Level
o At 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 An external schema is also known as view schema.
o Each view schema describes the database part that a particular user
group is interested and hides the remaining database from that user
group.
o The view schema describes the end user interaction with database
systems.
14. What are Costs and Risks of database approach?
The database approach causes some additional costs and risks that must be
recognized and managed when implementing this approach.
25
maintenance costs. Installing such a system may also require upgrades to
the hardware and data communications systems in the organization.