©) studocu
4th-sem-dbms notes (abhimanu)By: Abhimanu Yadav
Introduction of Database D
Purpose of database system
View of data
Database languages
Transaction management
Database administrator
System structure
Data is commonly defined as raw facts or observation, typically about physical phenomena or
business transactions. For example of data would be the marks obtained by students in
different subjects. Data can be in any form-numerical, textual, graphical, image, sound, video
etc.
The following figure shows the hierarchy of data storage.
Bit
Character
Field
Record
File
Database
Fig:- Data storage hierarchy
Information:
Information is defined as refined or processed data that has been transformed into
meaningful and useful form for specific users. For example, after processing the marks
obtained by student it transformed into information, which is meaningful and from which
we can decide which student stood first, second and so forth. Information comes from data
and takes the form of table, graphs, diagrams etc.
1
» €studocu
Downloaded by Mana Edt (
[email protected])
‘his document i avBy: Abhimanu Yadav
Database:
A database is an organized collection of data and contains information relevant to an
enterprise. The database is also called the repository or container for a collection of data files.
For example, university database for maintaining information about students, courses and
grades in university.
Characteristics of data in database:
The data in a database should have the following features:
"Shared: Data should be sharable among different users and applications.
* Persistence: Data should exist permanently in the database. Changes in the database
must not be lost because of any failure.
* Validity/Integrity/Correctness: It should maintain the integrity so that there is always
correct data in the database.
+ Security: Data should be protected from unauthorized access.
+ Non-redundancy: Data should not be repeated.
* Consistency: A consistent state of the database satisfies all the constraints specified in
the database. Data in a database is consistent if any changes in the database take the
database from one consistent state to another.
«Independence: The three levels in the schema should be independent of each other so
that the changes in the schema in one level should not affect the other levels.
Database Management System:
A Database Management System (DBMS) is a collection of interrelated data and the set of
programs to access those data. The primary goal of a DBMS is to provide a way to store and
retrieve database information that is both convenient and efficient.
For example, in a computer system, the checking account processing system, the auto loan
system and the saving accounts would have a common database. This database based
approach to data processing is shown in fig below:
Organizational
Checking Account
| | Program
Database Management
database
system (DBMS) |*> auto toan program
Saving Account
Fig: Database approach to data processing
Program
Downloaded by Mana Edt (manaedtuu@gmalcom)By: Abhimanu Yadav
Objective of DBMS
‘The DBMS is able
"To provide large space or storage for relevant data.
+ To provide easy access to the data for the users.
+ To provide quick response to user request for any data,
* To remove duplicate (redundant) data.
* To update the database latest modification immediately.
* To allow the multiple users to be active at one time.
* As the organization grows, DBMS allows the growth of the database system.
* To provide maximum protection to data from any physical damage and unauthorized
a
.
Database system:
‘A database system consists of database, database Management system, and application
program. A database system is just a computerized record keeping system. Database is a
repository for a collection of computerized data files. Users of database system can perform a
variety of operation on such file.
‘Some common examples of the DBMS software are Oracle, Sybase, Microsoft SQL Server,
DB2, MySQL, Postgres, Dbase, Ms-Access etc.
Applications of DBMS:
Databases form an essential part of almost all enterprises. Some database applications are
given below:
= Banking: For customer information and all transactions
* Airlines: For reservations and schedules information
= Universities: For the student information , course registration and grades
= Credit and transaction: For purchase credit cards and generates monthly statement
= Telecommunication: Keeping records of all the telephone calls, generating monthly
bills ete.
= Finance: For storing financial information
* Sales :For customers, products and purchases information
= Manufacturing: For tacking production, inventory, orders, supply chain management
= Human resources: For storing the information about employee records, salaries, tax
deductions
Flat-file Systems:
A flat file system stores data in a plain text file. A flat file is a file that contains records, and in
which each record is specified in a single line. Fields from each record may simply have a fixed
width with padding, or may be delimited by whitespace, tabs, commas or other characters.
Extra formatting may be needed to avoid delimiter collision. There ate no structural
3
» €studocu
Downloaded by Mana Edt (
[email protected])
‘his document i avBy: Abhimanu Yadav
relationships, The data are "flat"
as a relational database.
as in a sheet of paper, in contrast to more complex models such
For example, in a computer system, the checking account processing system would have its own
data files. This file based approach to data processing is shown in fig below:
(Checking Account
Checking Account Programs
Data Files
Fig: File-based approach to data processing
Limitations of Flat File System:
Keeping organizational information in a file-processing system has a number of major
disadvantages:
> Data redundancy: 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 cos!
> Data inconsistency: 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.
> Difficulty in accessing data: Conventional file-processing environments do not
allow needed data to be retrieved in a convenient and efficient manner
Data isolation: 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.
Integrity problems: The problem of integrity is the problem of ensuring that the data
in database is correct afler and before the transaction, For example, the balance of a
bank account may never fall below a prescribed amount (say, $25). When new
constraints are added, we have to change the programs to enforce them.
Atomicity problems: Execution of transactions must be atomic. This means
transactions must execute at its entirety or not at all. Consider a program to transfer
$50 from account 4 to account B. If a system failure occurs during the execution of
the program, it is possible that the $50 was removed from account 4 but was not
credited to account B, resulting in an inconsistent database state. It is difficult to
ensure atomicity in a conventional file-processing system.
Concurrent-access anomalies: 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, if
the programs executing on behalf of each withdrawal read the old balance
> 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 database that has information about the various bank employees. They do
v
v
v
v
4
Downloaded by Mana Edt (
[email protected]By: Abhimanu Yadav
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 in flat file system.
Purpose of DBMS (Functions of DBMS):
The benefits of using DBMS are:
> To reduce redundancy: Repeating of the same information in database is called
redundancy of data which leads to several problems such as wastage of space,
duplication effort for entering data and inconsistency. When DBMS is used and
database is created, redundancy is minimized,
To avoid inconsistency: The database is said to be inconsistent if various copies of
the same data may no longer agree. For example, a changed customer address may be
reflected in saving account but not elsewhere in the system. By using DBMS we can
avoid inconsistency.
To share data: The data in the database can be shared among many users and
applications. The data requirements of new applications may be satisfied without
having to create any new stored files
To provide support for transactions: A transaction is a sequence of database
operations that represents a logical unit of work. It accesses a database and transforms
it from one state to another. A transaction can update a record, delete one, modify a
set of records etc. when the DBMS does a ‘commit’, the changes made by the
transaction are made permanent, We can roll back the transaction to undo the effects
of transaction.
> To maintain integrity: Most database applications have certain integrity constraints
that must hold for the data. A DBMS provides capabilities for defining and enforcing
these constraints, For example, the value of roll number field of each student in
student database should be unique for each student. It is a type of rule, Such a rule is
enforced using constraint at the time of creation of database.
To enforce security: Not every user of the database system should be able to access
all data, Different checks can be established for each type of access (retrieve, modify,
delete, etc) to each piece of information in the database.
To provide efficient backup and recovery: Provide facilities for recovering from
software and hardware failures to restore database to previous consistent state,
> To Concurrent Access Database: Concurrent access means access to the same data
simultaneously by more than one user. The same data may be used by many users for
the purpose reading at the same time. But when a user tries to modify a data, there
should be a concurrency control mechanism to avoid the inconsistency of data. A
DBMS provides facilities for these operations.
v
v
v
v
v
Disadvantages of DBMS
«Problem associated with centralization: Centralization increases the security problems.
= Cost of software: Today’s there are several softwares which are very costly. Hence from
economic point of view it is the drawback.
» €studocu
Downloaded by Mana Edt (
[email protected])
‘his document i avBy: Abhimanu Yadav
* Cost of hardware: To support various software some upgraded hardware components
are needed. Hence from economic point of view it is the drawback,
+ Complexity of backup and recovery: DBMS provides the centralization of the data,
which requires the adequate backups of data.
* Overhead for providing generality, security, recovery, integrity, and
control.
* Ifthe database and applications are simple, well defined, and not expected to change.
= If there are stringent real-time requirements that may not be met because of DBMS
concurrency
overhead.
Differences bet” DBMS and file processing system:
1
‘A Database Management System
(DBMS) is a collection of interrelated
data and the set of programs to access
those data
1
A flat file system stores data in a plain
text file. A flat file is a file that contains
records, and in which each record is
specified in a single line.
2. Data redundancy problem is not found. | 2, Data redundancy problem exist.
3. Data inconsistency does not exist. 3. Data inconsistency may exist.
4. Accessing data from database is easier. | 4. Accessing data from database is
comparatively difficult.
5. The problem of data isolations is not | 5. Here data are scattered in various files
found. and formats so data isolation problem
6. Atomicity and integrating problems | — exist.
are not found. 6. Here these problems are found.
7. Data are more secure 7. Data are less secure.
8. Concurrent access and crash recovery. | 8. Here there is no concurrent access and
no recovery.
Views of Data/ Data abstraction
The system hides certain details of how the data are stored and maintained and such view
is an abstract view.
¥ The Database System provides users with an abstract view of the data
Data Abstractior
- The database designers use the complex data structure to represent the
data in the database and developer hides the complexity from user from several level of
abstraction such as physical level, logical level, and view level. This process is called data
abstraction.
Downloaded by Mana Edt (manaedkuu@gmalcoBy: Abhimanu Yadav
Levels of Data Abstraction:
‘The three levels of data abstraction can be shown as follows:
External view
View 1 View 2
View n
View level
Conceptual Level
Internal Level
Logical Level
I
Physical Level
stored database a) C_] [_]
Physical level
It is the lowest level of abstractions describes how the data are actually stored.
The physical level describes complex low level data structure in details.
v
v
v
v
Y Ibis the next higher level of data abstraction which describes what data are stored in the
At this level records such as customer, account can be described as a block of consecutive
Three levels of data abstraction
storage location (e.g. byte, word)
The database system hides many of the lowest level storage details from database
programmer. Database administrator may be aware of certain details of the physical
organization of the data.
Logical level
database, and what relationships exist among those data
Y At the logical level , each record is described by a type definition
Y Programmers and database administrator works at this level of abstraction.
View level
Y It is the highest level of abstraction describes only a part of the database and hides some
v
information to the user.
‘At view level, computer users see a set of application programs that hide details of data
types. Similarly at the view level several views of the database are defined and database
user see only these views.
Views also provides the security mechanism to prevent users from accessing certain parts
of the database (that is views can also hide information (such as an employee's salary) for
security purposes.)
7
eo © studocu
Downloaded by Mana Edt (
[email protected])
‘This documentBy: Abhimanu Yadav
Instances and Schemas
instance (Database State):
The collection of information stored in the database at a particular moment is called an
instance of the database. Itis the actual content of the database at a particular point in time
Y The term instance is also applied to individual database components, ¢.g. record instance, table
instance, entity instance.
Initial Database State
Refers to the database state when it is initially loaded into the system.
Valid State
A state that satisfies the structure and constraints of the database.
Schem:
The overall design of the database which is not expected to change frequently is called
database schema. Simply, the database schema is the logical structure of the database.
Y The concept of database schema and instances can be understood by analogy to a
program written in a programming language
YA database schema corresponds to the variable declaration and the values of the variables,
in a program at a point in time correspond to an instance of a database.
Y The database systems have several schemas and partitioned according to the level of
abstraction such as physical and logical schema,
STUDENT.
Fig: Schema diagram for Student
Note:
Y The database schema changes very infrequently.
Y The database state changes every time the database is updated
Data Independence
The three schema architecture further explains the concept of data independence, the capacity to
change the schema at one level without having to change the schema at the next higher level.
> Logical Data Independence
> Physical Data Independence
Logical Data Independence:
‘The capacity to change the conceptual schema without having to change the external schemas
and their associated application programs is called logical data independence. When
modification is done to the conceptual schema (i.e tables) the mapping called “external mapping”
is changes automatically by DBMS.
Downloaded by Mana Edt (manaedtuu@gmal com)