Database Management System
Database Management System
MODULE-1
Q1- Discuss the main characteristics of database approach. How it differ from
traditional database.
Ans-
FILE ORIENTED APPROACH:A DBMS utilizes a variety of sophisticated techniques to store and
retrieve data efficiently. This feature is especially important if the data is stored on external
storagedevices.
If data is always accessed through the DBMS, the DBMS can enforce integrity constraints on the data. For
example, before inserting salary information for an employee, the DBMS can check that the department
budget is not exceeded. Also, the DBMS can enforce access controls that govern what data is visible to
different classes of users.
1. File system is a collection of data. Any management with the file system, user has
to write theprocedures.
2. File system gives the details of the data representation and Storage ofdata.
3. In File system storing and retrieving of data cannot be doneefficiently.
4. Concurrent access to the data in the file system has many problems like a
Reading the file while other deleting some information, updating someinformation
5. File system doesn’t provide crash recoverymechanism.
Eg. While we are entering some data into the file if System crashes then content of
the file is lost.
6. Protecting a file under file system is verydifficult.
The typical file-oriented system is supported by a conventional operating system.
Permanent records are stored in various files and a number of different application programs
are written to extract records from and add records to the appropriate files.
Since files and application programs are created by different programmers over a long
period of time, the files are likely to be having different formats and the programs may be
written in several programming languages. Moreover, the same piece of information may be
duplicated in several places. This redundancy leads to higher storage and access cost. In
addition, it may lead to data inconsistency.
The conventional file processing environments do not allow needed data to be retrieved
in a convenient and efficient manner. Better data retrieval system must be developed for
general use.
Data Isolation:
Since data is scattered in various files, and files may be in different formats, it is
difficult to write new application programs to retrieve the appropriate data.
In order to improve the overall performance of the system and obtain a faster response
time, many systems allow multiple users to update the data simultaneously. In such an
environment, interaction of concurrent updates may result in inconsistent data.
Security Problems:
Not every user of the database system should be able to access all the data. For
example, in banking system, payroll personnel need only that part of the database that has
information about various bank employees. They do not need access to information about
customer accounts. It is difficult to enforce such security constraints.
Integrity Problems:
The data values stored in the database must satisfy certain types of consistency
constraints. For example, the balance of a bank account may never fall below a prescribed
amount. These constraints are enforced in the system by adding appropriate code in the various
application programs. When new constraints are added, it is difficult to change the programs to
enforce them. The problem is compounded when constraints involve several data items for different
files.
Atomicity Problem:
A computer system like any other mechanical or electrical device is subject to failure.
In many applications, it is crucial to ensure that once a failure has occurred and has been
detected, the data are restored to the consistent state existed prior to the failure
Example:
Consider part of a savings-bank enterprise that keeps information about all customers
and savings accounts. One way to keep the information on a computer is to store it in operating
system files. To allow users to manipulate the information, the system hasa number of
application programs that manipulate the files,including:
The address and telephone number of a particular customer may appear in a file that
consists of savings-account records and in a file that consists of checking-account records. This
redundancy leads to higher storage and access cost. In, it may lead to data inconsistency; that is,
the various copies of the same data may no longer agree. For example, a changed customer
address may be reflected in savings-account records but not elsewhere in the system.
2. Difficulty in AccessingData:
Suppose that one of the bank officers needs to find out the names of all customers
who live within a particular postal-code area. The officer asks the data-processing department
to generate such a list. Because there is no application program to generate that. The bank
officer has now two choices: either obtain the list of all customers and extract the needed
information manually or ask a system programmer to write the necessary application program.
Both alternatives are obviouslyunsatisfactory.
3. DataIsolation:
Because data are scattered in various files and files may be in different formats,
writing new application programs to retrieve the appropriate data is difficult.
4. Integrity Problems:
The balance of a bank account may never fall below a prescribed amount (say, $25).
Developers enforce these constraints in the system by adding appropriate code in the various
application programs. However, when new constraints are added, it is difficult to change the
programs to enforce them. The problem is compounded when constraints involve several data
items from different files.
5. Atomicity Problems:
A computer system, like any other mechanical or electrical device, is subject to failure.
In many applications, it is crucial that, if a failure occurs, the data be restored to the consistent
state that existed prior to the failure. Consider a program to transfer $50 from account A to
account B. If a system failure occurs during the execution of the program, it is possible that the
$50 was removed from account A but was not credited to account B, resulting in an inconsistent
database state. Clearly, it is essential to database consistency that either both the credit and
debit occur, or that neither occur. That is, the funds transfer must beatomic—it must happen in
its entirety or not at all. It is difficult to ensure atomicity in a conventional file-
processingsystem.
6. Concurrent-AccessAnomalies:
For the sake of overall performance of the system and faster response, many systems
allow multiple users to update the data simultaneously. In such an environment, interaction of
concurrent updates may result in inconsistent data. Consider bank account A, containing
$500. If two customers withdraw funds (say $50 and $100 respectively) from account A at
about the same time, the result of the concurrent executions may leave the account in an
incorrect (or inconsistent) state. Suppose that the programs executing on behalf of each
withdrawal read the old balance, reduce that value by the amount being withdrawn, and write
the result back. If the two programs run concurrently, they may both read the value $500, and
write back $450 and $400, respectively. Depending on which one writes the value last, the
account may contain $450 or $400, rather than the correct value of $350. To guard against
this possibility, the system must maintain some form of supervision. But supervision is difficult
to provide because data may be accessed by many different application programs that have not
been coordinated previously.
7. Security Problems:
Not every user of the database system should be able to access all the data. For example,
in a banking system, payroll personnel need to see only that part of the databasethat has
information about the various bank employees. They do not need access to information about
customer accounts. But, since application programs are added to the system in an ad hoc
manner, enforcing such security constraints is difficult. These difficulties, among others,
prompted the development of databasesystems.
ADVANTAGES OF A DBMS OVER FILE SYSTEM:
Data Independence:
DBMS supports many important functions that are common to many applications
accessing data stored in the DBMS. This, in conjunction with the high-level interface to the
data, facilitates quick development of applications. Such applications are also likely to be
more robust than applications developed from scratch because many important tasks arehandled
by the DBMS instead of being implemented by theapplication.
Q2-Describe the three schema architecture. What are the problems associated
with three schema architecture.
The goal of this architecture is to separate the user applications and the physical
database. In this architecture, schemas can be defined at the following threelevels:
1. The internal level has an internal schema, which describes the physical storage structure
of the database. The internal schema uses a physical data model and describes the complete
details of data storage and access paths for thedatabase.
2. The conceptual level has a conceptual schema, which describes the structure of the whole
database for a community of users. The conceptual schema hides the details of physical
storage structures and concentrates on describing entities, data types, relationships, user
operations, and constraints. A high-level data model or an implementation data model can
be used at thislevel.
3. The external or view level includes a number of external schemas or user views. Each
external schema describes the part of the database that a particular user group is interested
in and hides the rest of the database from that user group. A high-level data model or an
implementation data model can be used at thislevel.
Q3- Explain the component modules of DBMS and their interaction, with the
help of a diagram.
Ans-DATABASE SYSTEM ENVIRONMENT ( DBMS COMPONENT MODULES)
A database system is partitioned into modules that deal with each of the responsibilities
of the overall system. The functional components of a database system can be broadly divided
into the storage manager and the query processorcomponents.
The storage manager is important because databases typically require a large amountof
storage space. Some Big organizations Database ranges from Giga bytes to Tera bytes. So the
main memory of computers cannot store this much information, the information is stored on
disks. Data are moved between disk storage and main memory asneeded.
The query processor also very important because it helps the database system simplify and
facilitate access to data. So quick processing of updates and queries is important. It is the job of the
database system to translate updates and queries written in a nonprocedurallanguage,
StorageManager:
A storage manager is a program module that provides the interface between the
low level data stored in the database and the application programs and queries submitted
to the system. The storage manager is responsible for the interaction with the file manager.
The storage manager translates the various DML statements into low-level file-system
commands. Thus, the storage manager is responsible for storing, retrieving, and updating
data in the database.
File manager: which manages the allocation of space on disk storage and
the data structures used to represent information stored on disk.
Buffer manager which is responsible for fetching data from disk storage into main
memory. Storage manager implements several data structures as part of the physical
system implementation. Data files are used to store the database itself. Data dictionary is
used to stores metadata about the structure of the database, in particular the schema of the
database.
DDL interpreter: It interprets DDL statements and records the definitions in the data
dictionary.
DML compiler: It translates DML statements in a query language into an evaluation plan
consisting of low-level instructions that the query evaluation engine understands.
Application Architectures:
Most users of a database system today are not present at the site of the database
system, but connect to it through a network. We can therefore differentiate between
client machines,on which remote database users’ work, and server machines, on which the
database system runs. Database applications are usually partitioned into two or three parts.
They are:
The ability to modify the physical schema without causing application programs
to be rewritten
Modifications at this level are usually to improve performance.
The ability to modify the conceptual schema without causing application programs
to be rewritten
Usually done when logical structure of database is altered.
Logical data independence is harder to achieve as the application programs are
usually heavily dependent on the logical structure of the data.
ER Model: Attributes
If a Student is an Entity, then student's roll no., student's name, student's age, student's
gender etc will be its attributes.
An attribute can be of many types, here are different types of attributes defined in ER
database model:
1. Simple attribute: The attributes with values that are atomic and cannot be broken
down further are simple attributes. For example, student's age.
2. Composite attribute: A composite attribute is made up of more than one simple
attribute. For example, student's address will contain, house no., street name, pin
code etc.
3. Derived attribute: These are the attributes which are not present in the whole
database management system, but are derived using other attributes. For
example, average age of students in a class.
4. Single-valued attribute: As the name suggests, they have a single value.
5. Multi-valued attribute: they can have multiple values.
ER Model: Keys
If the attribute roll no. can uniquely identify a student entity, amongst all the students, then
the attribute roll no. will be said to be a key.
Following are the types of Keys:
1. Super Key
2. Candidate Key
3. Primary Key
ER Model: Relationships
When an Entity is related to another Entity, they are said to have a relationship. For
example, A Class Entity is related to Student entity, because students study in classes, hence
this is a relationship.
Depending upon the number of entities involved, a degree is assigned to relationships.
For example, if 2 entities are involved, it is said to be Binary relationship, if 3 entities are
involved, it is said to be Ternary relationship, and so on.
Working with ER Diagrams
ER Diagram is a visual representation of data that describes how data is related to each other.
In ER Model, we disintegrate data into entities, attributes and setup relationships between
entities, all this can be represented visually using the ER diagram.
For example, in the below diagram, anyone can see and understand what the diagram wants
to convey: Developer develops a website, whereas a Visitor visits a website.
Components of ER Diagram
Entitiy, Attributes, Relationships etc form the components of ER Diagram and there are
defined symbols and shapes to represent each one of them.
Let's see how we can represent these in our ER Diagram.
Entity
Simple rectangular box represents an Entity.
Weak Entity
A weak Entity is represented using double rectangular boxes. It is generally connected to
another entity.
ER Diagram: Attribute
An Attribute describes a property or characteristic of an entity. For
example, Name, Age, Address etc can be attributes of a Student. An attribute is represented
using eclipse.
ER Diagram: Key Attribute
Key attribute represents the main characteristic of an Entity. It is used to represent a Primary
key. Ellipse with the text underlined, represents Key Attribute.
ER Diagram: Composite Attribute
An attribute can also have their own attributes. These attributes are known
as Composite attributes.
ER Diagram: Relationship
A Relationship describes relation between entities. Relationship is represented using
diamonds or rhombus.
1. Binary Relationship
2. Recursive Relationship
3. Ternary Relationship
The above diagram represents that one student can enroll for more than one courses. And a
course can have more than 1 student enrolled in it.
1. Generalization
2. Specialization
3. Aggregation
Generalization
Generalization is a bottom-up approach in which two lower level entities combine to form a
higher level entity. In generalization, the higher level entity can also combine with other
lower level entities to make further higher level entity.
It's more like Super class and Subclass system, but the only difference is the approach, which
is bottom-up. Hence, entities are combined to form a more generalised entity, in other words,
sub-classes are combined to form a super-class.
For example, Saving and Current account types entities can be generalised and an entity
with name Account can be created, which covers both.
Specialization
Specialization is opposite to Generalization. It is a top-down approach in which one higher
level entity can be broken down into two lower level entity. In specialization, a higher level
entity may not have any lower-level entity sets, it's possible.
Aggregation
Aggregation is a process when relation between two entities is treated as a single entity.
In the diagram above, the relationship between Center and Course together, is acting as an
Entity, which is in relationship with another entity Visitor. Now in real world, if a Visitor or
a Student visits a Coaching Center, he/she will never enquire about the center only or just
about the course, rather he/she will ask enquire about both.
The file management system also called as FMS in short is one in which all data
is stored on a single large file. The main disadvantage in this system is searching arecord
or data takes a long time. This lead to the introduction of the concept, of indexing in this
system. Then also the FMS system had lot of drawbacks to name a few like updating or
modifications to the data cannot be handled easily, sorting the records took long time and
so on. All these drawbacks led to the introduction of the Hierarchical DatabaseSystem.
The previous system FMS drawback of accessing records and sorting records
which took a long time was removed in this by the introduction of parent-child
relationship between records in database. The origin of the data is called the root from
which several branches have data at different levels and the last level is called the leaf.
The main drawback in this was if there is any modification or addition made to the structure
then the whole structure needed alteration which made the task a tedious one. In order to
avoid this next system took its origin which is called as the Network DatabaseSystem.
In this the main concept of many-many relationships got introduced. But this also
followed the same technology of pointers to define relationships with a differencein this
made in the introduction if grouping of data items as sets.
In order to overcome all the drawbacks of the previous systems, the Relational
Database System got introduced in which data get organized as tables and each record
forms a row with many fields or attributes in it. Relationships between tables are also
formed in this system.
Q9.What are different database schema languages and interfaces?
Ans-
Database Language.
o A DBMS has appropriate languages and interfaces to express database queries and updates.
o Database languages can be used to read, store and update the data in the database.
(i)DDL
(ii)DML
(iii)DCL
(iv)TCL
(But in Oracle database, the execution of data control language does not have the feature of
rolling back.)
There are the following operations which have the authorization of Revoke:
Interfaces in DBMS
A database management system (DBMS) interface is a user interface which allows for
the ability to input queries to a database without using the query language itself.