45
BASICS OF DATABASE MANAGEMENT SYSTEM By Parteek Bhatia Sr. Lecturer Department of Comp Sc & Engineering Thapar University Patiala

Basics-of-DBMS

Embed Size (px)

DESCRIPTION

Dbms basics

Citation preview

Page 1: Basics-of-DBMS

BASICS OFDATABASE MANAGEMENT SYSTEM

ByParteek Bhatia

Sr. LecturerDepartment of Comp Sc & Engineering

Thapar UniversityPatiala

Page 2: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Understanding Databases

What is Data and Information?

Data is the term, that may be new to beginners, but it is very

interesting and simple to understand. It can be anything like

name of a person or a place or a number etc. Data is the name

given to basic facts and entities such as names and numbers.

The main examples of data are weights, prices, costs, numbers

of items sold, employee names, product names, addresses, tax

codes, registration marks etc.

Page 3: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Information: Information is data that has been converted into

a more useful or intelligible form. It helps human beings in

their decision making process. Examples are: Time Table,

Merit List, Report card, Headed tables, printed documents,

pay slips, receipts, reports etc. The information is obtained by

assembling items of data into a meaningful form.

For example, marks obtained by students and their roll

numbers form data, the report card/sheet is the information.

Page 4: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Difference between Data and Information

Page 5: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Page 6: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Database

The related information when placed is an organized form

makes a database. The organization of data/information is

necessary because unorganized information has no meaning.

In dictionary, the words are arranged in alphabetic order

along with their meanings.

Page 7: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

There are so many operations like:

¨ To add new information (e.g. to add the address of a new

friend in your address book)

To view or retrieve the stored information (e.g. you

have to find the address of one of your old friends)

¨ To modify or edit the existing information (e.g. your

friend has shifted to a new place so his address would get

changed)

¨ To remove or delete the unwanted information (e.g. your

friend has changed his/her mobile number, so his/her mobile

number would have to be removed from list)

¨ Arranging the information in a desired order etc.

Page 8: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Manual database and its problems

Consider an example of accounts department of an

organization. To make the salary calculations of the employees

every month they are to keep the record of every employee and

do a number of calculations such as addition of allowances like

DA, HRA to the basic salary and to make several deductions as

loan recoveries, income tax and insurance etc and at the end, to

make the pay slips of the net pay. This whole procedure is

repeated every month and is very tedious and laborious job.

It’s a mere calculation job and does not require any logic or

intelligence. So to waste the skills and intelligence of human

beings on such repetitive calculations is not a wise decision.

Page 9: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Database and Computers

¨ Computer has a large storage capacity. It can store

thousands of records at a time.

¨ It has high speed, within no time it searches any desired

information, arrange the data in alphabetical order, do

calculations on the data and make repetitions and so on.

¨ Computer is more accurate.

¨ Data in computers can be stored in the form of a file,

records and fields.

¨ There are two approaches for storing data in computers

such as File based approach and Database approach.

Page 10: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

File Based Approach

File Based system: File-based systems were an early attempt

to computerize the manual filing system that we are all

familiar with.

A file system is a method for storing and organizing

computer files and the data they contain to make it easy to

find and access them.

File systems may use a storage device such as a hard disk or

CD-ROM and involve maintaining the physical location of

the files

Page 11: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Flat File

Each file called a flat file, contained and processed

information for one specific function, such as accounting or

inventory. Programmers used programming languages such as

COBOL, C++ to write applications that directly accessed flat

files to perform data management services and provide

information for users.

Page 12: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

There are following problems associated with the File Based

Approach:

• Separated and Isolated Data

• Duplication of data

•Data Dependence

•Difficulty in representing data from the user’s view

•Data Inflexibility

•Incompatible file formats

Limitations of the File-Based Approach

Page 13: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Page 14: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Page 15: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Database Approach

In order to remove all the above limitations of the File Based

Approach, a new approach was required that must be more

effective known as Database approach.

A database is a computer based record keeping system whose

over all purpose is to record and maintain information. The

database is a single, large repository of data, which can be

used simultaneously by many departments and users.

Page 16: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

The Database Management System (DBMS)

DBMS A database management system is the software

system that allows users to define, create and maintain a

database and provides controlled access to the data.

A database management system (DBMS) is basically a

collection of programs that enables users to store, modify, and

extract information from a database as per the requirements.

DBMS is an intermediate layer between programs and the data.

Programs access the DBMS, which then accesses the data. There

are different types of DBMS ranging from small systems that

run on personal computers to huge systems that run on

mainframes. The following are main examples of database

applications:

Page 17: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Computerized library systems

¨ Automated teller machines

¨ Flight reservation systems

¨ Computerized parts inventory systems

Commercially available Database management systems in the

market are dbase, Foxpro, IMS and Oracle.

These systems allow users to create, update, and extract

information from their databases. Compared to a manual filing

system, the biggest advantages to a computerized database

system are speed, accuracy, and accessibility.

Page 18: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Components of the DBMS Environment

•Hardware

•Software

•Data

•Users

•Procedures

Page 19: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Hardware

The hardware is the actual computer system used for

keeping and accessing the database. Conventional DBMS

hardware consists of secondary storage devices, usually

hard disks, on which the database physically resides,

together with the associated

Page 20: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Software

The software is the actual DBMS. Between the physical

database itself (i.e. the data as actually stored) and the

users of the system is a layer of software, usually called

the Database Management System or DBMS. All requests

from users for access to the database are handled by the

DBMS.

One general function provided by the DBMS is thus the

shielding of database users from complex hardware-level

detail.

Page 21: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Data

The database should contain all the data needed by the

organization. One of the major features of databases is that

the actual data are separated from the programs that use the

data. A database should always be designed, built and

populated for a particular audience and for a specific purpose.

Page 22: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Users

There are a number of users who can access or retrieve data

on demand using the applications and interfaces provided by

the DBMS. Each type of user needs different software

capabilities. The users of a database system can be classified

in the following groups, depending on their degrees of

expertise or the mode of their interactions with the DBMS.

Page 23: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

The users can be:

¨ Naive Users

¨ Online Users

¨ Application Programmers

¨ Sophisticated Users

¨ DBA

Page 24: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Advantages of DBMS

Controlling Redundancy

Page 25: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Integrity can be enforced

Integrity of data means that

data in database is always

accurate, such that incorrect

information cannot be stored

in database. In order to

maintain the integrity of

data, some integrity

constraints are enforced on

the database. A DBMS

should provide capabilities

for defining and enforcing

the constraints.

Page 26: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Inconsistency can be avoided

When the same data is duplicated and changes are made at one site, which

is not propagated to the other site, it gives rise to inconsistency and the two

entries regarding the same data will not agree. At such times the data is

said to be inconsistent. So if the redundancy is removed chances of having

inconsistent data is also removed.

Let us again consider the college system and suppose that in case of

General_Office file it is indicated that Roll_Number 5 lives in Amritsar but

in library file it is indicated that Roll_Number 5 lives in Jalandhar. Then

this is a state at which the two entries of the same object do not agree with

each other (that is one is updated and other is not). At such time the

database is said to be inconsistent.

Page 27: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

In case of DBMS, Roll number and address occurs together

only single time in General_Office table. So, it needs single

updation and then all other application retrieve the address

information from General_Office which is updated so, all

application will get the current and latest information by

providing single update operation and this single update

operation is propagated to the whole database or all other

application automatically, this property is called as

Propagation of Update.

Page 28: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

•Data can be shared

•Providing Backup and Recovery

•Standards can be enforced

•Restricting unauthorized access

•Solving enterprise requirement than individual

requirement

Page 29: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

•Complexity

•Size

•Performance

•Higher impact of a failure

•Cost of DBMS

•Additional Hardware costs

•Cost of Conversion

Disadvantages of DBMS

Page 30: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

An early proposal for a standard terminology and general architecture

for database systems was produced in 1971 by the DBTG (Data

Base Task Group) appointed by the Conference on Data Systems and

Languages (CODASYL, 1971). The DBTG recognized the need for a

two level approach with a system view called the schema and user

views called subschema. The American National Standards Institute

(ANSI) recognized the need for a three level approach with a system

catalog.

Three Level Architecture

Page 31: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

There are following three levels or layers of DBMS architecture:

¨ External Level

¨ Conceptual Level

¨ Internal Level

Page 32: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Objective of the Three Level Architecture

¨ Each user should be able to access the same data, but

have a different customized view of the data.

¨ User’s interaction with the database should be

independent of storage considerations.

Page 33: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

¨ The Database Administrator (DBA) should be able to

change the database storage structures without affecting the

user’s views.

¨ The internal structure of the database should be

unaffected by changes to the physical aspects of storage, such

as the changeover to a new storage device.

¨ The DBA should be able to change the conceptual

structure of the database without affecting all users.

Page 34: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Page 35: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

External Level or View level

It is the users’ view of the database. This level describes that

part of the database that is relevant to each user. External level

is the one, which is closest to the end users. This level deals

with the way in which individual users view data. Individual

users are given different views according to the user’s

requirement.

External level is also known as the view level. In addition

different views may have different representations of the same

data. For example, one user may view dates in the form (day,

month, year), while another may view dates as (year, month,

day).

Page 36: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Conceptual Level or Logical level

It is the community view of the database. This level describes

what data is stored in the database and the relationships among

the data. The middle level in the three level architecture is the

conceptual level.

This level contains the logical structure of the entire database as

seen by the DBA. It is a complete view of the data requirements

of the organization that is independent of any storage

considerations. The conceptual level represents:

¨ All entities, their attributes, and their relationships;

¨ The constraints on the data;

¨ Security and integrity information.

.

Page 37: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Internal Level or Storage level

It is the physical representation of the database on the

computer. This level describes how the data is stored in the

database. The internal level is the one that concerns the way the

data are physically stored on the hardware.

The internal level covers the physical implementation of the

database to achieve optimal runtime performance and storage

space utilization. It covers the data structures and file

organizations used to store data on storage devices. It interfaces

with the operating system access methods to place the data on

the storage devices, build the indexes, retrieve the data, and so

on.

Page 38: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Schema

The overall description of the database is called the Database Schema.

There are three different types of schema in the database corresponding to

each data view of database. In other words, the data views at each of three

levels are described by schema.

A schema is defined as an outline or a plan that describes the records

and relationships existing at the particular level. The External view is

described by means of a schema called external schema that correspond to

different views of the data. Similarly the Conceptual view is defined by

conceptual schema, which describes all the entities, attributes, and

relationship together with integrity constraints. Internal View is defined by

internal schema, which is a complete description of the internal model,

containing definition of stored records, the methods of representation, the

data fields, and the indexes used.

Page 39: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Page 40: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Mapping between Views

External/Conceptual Mapping: Each external schema is related to the

conceptual schema by the external/conceptual mapping. A mapping between

the external and conceptual views gives the correspondence among the

records and the relationships of the external and conceptual views.. There is a

mapping from a particular logical record in the external view to one (or more)

conceptual record(s) in the conceptual view.

Names of the fields and records, for instance, may be different. A number of

conceptual fields can be combined into a single external field, for example,

Last_Name and First_Name at the conceptual level but Name at the external

level. A given external record could be derived from a number of conceptual

records.

Page 41: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Conceptual/Internal Mapping: Conceptual schema is related to the internal

schema by the conceptual/internal mapping. This enables the DBMS to find the

actual record or combination of records in physical storage that constitute a

logical record in conceptual schema. Mapping between the conceptual and the

internal levels specifies the method of deriving the conceptual record from the

physical database.

Differences between Conceptual/Internal Views

¨ Representation of numeric values could be different in the two views.

¨ Representation of string data can be considered by the two views to be

coded differently.

Page 42: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Data Independence-Achievement of Layered Architecture

of DBMS

There are two kinds of data independence:

¨ Logical data independence

¨ Physical data independence

Logical data independence

Logical data independence indicates that the conceptual

schema can be changed without affecting the existing external

schemas. The change would be absorbed by the mapping

between the external and conceptual levels.

Page 43: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

Physical data independence

Physical data independence indicates that the physical storage structures or

devices could be changed without affecting conceptual schema. The change

would be absorbed by the mapping between the conceptual and internal

levels. Physical data independence is achieved by the presence of the internal

level of the database and the mapping or transformation from the conceptual

level of the database to the internal level.

If there is a need to change the file organization or the type of physical device

used as a result of growth in the database or new technology, a change is

required in the conceptual/internal mapping between the conceptual and

internal levels.

The physical data independence criterion requires that the conceptual level

does not specify storage structures or the access methods (indexing, hashing

etc.) used to retrieve the data from the physical storage medium.

Page 44: Basics-of-DBMS

Simplified Approach to DBMS

By Parteek Bhatia

The Logical data independence is difficult to achieve than

physical data independence as it requires the flexibility in the

design of database and programmer has to foresee the future

requirements or modifications in the design.

Page 45: Basics-of-DBMS

References

Simplified Approach to DBMS

Kalyani Publishers

By

Parteek Bhatia